This commit is contained in:
ubuntu 2023-12-17 11:21:46 +08:00
parent a5e4495ee5
commit 0e8b26d84f
3 changed files with 32 additions and 28 deletions

View File

@ -50,13 +50,6 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
ParserKeyword s_having("HAVING");
ParserKeyword s_window("WINDOW");
ParserKeyword s_order_by("ORDER BY");
ParserKeyword ascending("ASCENDING");
ParserKeyword descending("DESCENDING");
ParserKeyword asc("ASC");
ParserKeyword desc("DESC");
ParserKeyword nulls("NULLS");
ParserKeyword first("FIRST");
ParserKeyword last("LAST");
ParserKeyword s_limit("LIMIT");
ParserKeyword s_settings("SETTINGS");
ParserKeyword s_by("BY");
@ -281,7 +274,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
/// if any WITH FILL parse possible INTERPOLATE list
if (std::any_of(order_expression_list->children.begin(), order_expression_list->children.end(),
[](auto & child) { return child->template as<ASTOrderByElement>()->with_fill; }))
[](auto & child) { return child->template as<ASTOrderByElement>()->with_fill; }))
{
if (s_interpolate.ignore(pos, expected))
{

View File

@ -1,20 +1,28 @@
A 3
B 1
A 2
B 3
C \N
B 1 1
A 3 2
B 3 2
C \N 3
B 1 1
B 3 2
A 3 2
C \N 3
C \N
B 3
B 1
A 3
\N C
1 B
3 A
D 1
1 D
2 A
3 B
\N C
B 3 10
D 1 20
A 2 30
C \N 40
D 1
A 2
B 3
C \N
B 3 10
D 1 20
A 2 30
C \N 40
D 1
C \N
B 3
A 2
\N C
1 D
2 A
3 B

View File

@ -6,14 +6,17 @@ CREATE TABLE order_by_all
b Nullable(Int32),
all int,
)
engine = Memory;
engine = Memory;
INSERT INTO order_by_all VALUES ('B', 3, 2), ('C', NULL, 3), ('B', 1, 1), ('A', 3, 2);
INSERT INTO order_by_all VALUES ('B', 3, 10), ('C', NULL, 40), ('D', 1, 20), ('A', 2, 30);
SELECT a, b FROM order_by_all ORDER BY ALL;
SELECT b, a FROM order_by_all ORDER BY ALL;
SELECT a, b, all FROM order_by_all ORDER BY all; -- { serverError UNEXPECTED_EXPRESSION }
SELECT a, b, all FROM order_by_all ORDER BY all, a;
SELECT a, b as all FROM order_by_all ORDER BY all; -- { serverError UNEXPECTED_EXPRESSION }
SELECT a, b, all FROM order_by_all ORDER BY all settings enable_order_by_all = false;
SELECT a, b as all FROM order_by_all ORDER BY all settings enable_order_by_all = false;
SELECT a, b, all FROM order_by_all ORDER BY all, a;
SELECT a, b FROM order_by_all ORDER BY ALL DESC;
SELECT b, a FROM order_by_all ORDER BY ALL NULLS FIRST;