Change error code for DISTINCT ON and LIMIT BY, finally

This commit is contained in:
vdimir 2021-07-06 19:14:22 +03:00
parent 96536a9cbe
commit b44bd174cc
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
2 changed files with 3 additions and 3 deletions

View File

@ -20,8 +20,8 @@ namespace ErrorCodes
extern const int FIRST_AND_NEXT_TOGETHER;
extern const int LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED;
extern const int ROW_AND_ROWS_TOGETHER;
extern const int SYNTAX_ERROR;
extern const int TOP_AND_LIMIT_TOGETHER;
extern const int UNSUPPORTED_METHOD;
extern const int WITH_TIES_WITHOUT_ORDER_BY;
}
@ -286,7 +286,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
throw Exception("Can not use WITH TIES alongside LIMIT BY/DISTINCT ON", ErrorCodes::LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED);
if (distinct_on_expression_list)
throw Exception("Can not use DISTINCT ON alongside LIMIT BY", ErrorCodes::UNSUPPORTED_METHOD);
throw Exception("Can not use DISTINCT ON alongside LIMIT BY", ErrorCodes::SYNTAX_ERROR);
limit_by_length = limit_length;
limit_by_offset = limit_offset;

View File

@ -7,7 +7,7 @@ SELECT DISTINCT ON (a, b) a, b, c FROM t1;
SELECT DISTINCT ON (a, b) * FROM t1;
SELECT DISTINCT ON (a) * FROM t1;
SELECT DISTINCT ON (a, b) a, b, c FROM t1 LIMIT 1 BY a, b; -- { clientError 1 }
SELECT DISTINCT ON (a, b) a, b, c FROM t1 LIMIT 1 BY a, b; -- { clientError 62 }
SELECT DISTINCT ON a, b a, b FROM t1; -- { clientError 62 }
SELECT DISTINCT ON a a, b FROM t1; -- { clientError 62 }