-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionIssues or changes relating to SQL execution
Description
To reproduce
SELECT * FROM (
SELECT 456 AS "5"
UNION ALL
SELECT 789 AS "5"
UNION ALL
SELECT 123 AS "5"
)
ORDER BY "5"order column position is out of range [max=1]
There is ambiguity in two cases:
- When the column name is a number and outside of the range i.e.
2000and there are only 3 columns - When the column name is a number, and within the range, but the name doesn't match the position, like this:
3, 1, 2
ORDER BY 2 -- do we sort by column "1" or by column "2"? @Test
public void testOrderByWithNumericNamedColumnInsideOfRange() throws Exception {
assertException("select * from (" +
"select 200 as \"3\", 201 as \"1\", 202 as \"2\" " +
"union all " +
"select 500 as \"3\", 501 as \"1\", 502 as \"2\" " +
"union all " +
"select 50 as \"3\", 51 as \"1\", 52 as \"2\") " +
"order by 2", 123, "ambiguous order by column [name=2]");
}
@Test
public void testOrderByWithNumericNamedColumnOutsideOfRange() throws Exception {
assertQuery("999\n50\n200\n500", "select * from (" +
"select 200 as \"999\" " +
"union all " +
"select 500 as \"999\" " +
"union all " +
"select 50 as \"999\") " +
"order by \"999\"",
null, null,
false,
true);
}QuestDB version:
Master (8.2.2+)
OS, in case of Docker specify Docker and the Host OS:
N/A
File System, in case of Docker specify Host File System:
N/A
Full Name:
Nick Woolmer
Affiliation:
QuestDB
Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?
- Yes, I have
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionIssues or changes relating to SQL execution