mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-25 03:00:49 +00:00
Fix error for previous offset test
This commit is contained in:
parent
39367be57a
commit
dea965832a
@ -507,6 +507,8 @@ namespace ErrorCodes
|
||||
extern const int CANNOT_CREATE_RABBITMQ_QUEUE_BINDING = 541;
|
||||
extern const int CANNOT_REMOVE_RABBITMQ_EXCHANGE = 542;
|
||||
extern const int UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL = 543;
|
||||
extern const int ROW_AND_ROWS_TOGETHER = 544;
|
||||
extern const int FIRST_AND_NEXT_TOGETHER = 545;
|
||||
|
||||
extern const int KEEPER_EXCEPTION = 999;
|
||||
extern const int POCO_EXCEPTION = 1000;
|
||||
|
@ -19,6 +19,8 @@ namespace ErrorCodes
|
||||
extern const int TOP_AND_LIMIT_TOGETHER;
|
||||
extern const int WITH_TIES_WITHOUT_ORDER_BY;
|
||||
extern const int LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED;
|
||||
extern const int ROW_AND_ROWS_TOGETHER;
|
||||
extern const int FIRST_AND_NEXT_TOGETHER;
|
||||
}
|
||||
|
||||
|
||||
@ -197,56 +199,6 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
return false;
|
||||
}
|
||||
|
||||
/// OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES}
|
||||
if (s_offset.ignore(pos, expected))
|
||||
{
|
||||
/// OFFSET must exists with "order by"
|
||||
if (!order_expression_list)
|
||||
return false;
|
||||
|
||||
if (!exp_elem.parse(pos, limit_offset, expected))
|
||||
return false;
|
||||
|
||||
if (s_row.ignore(pos, expected))
|
||||
{
|
||||
if (s_rows.ignore(pos, expected))
|
||||
throw Exception("Can not use ROW and ROWS together", ErrorCodes::TOP_AND_LIMIT_TOGETHER);
|
||||
}
|
||||
else if (!s_rows.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (!s_fetch.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (s_first.ignore(pos, expected))
|
||||
{
|
||||
if (s_next.ignore(pos, expected))
|
||||
throw Exception("Can not use ROW and ROWS together", ErrorCodes::TOP_AND_LIMIT_TOGETHER);
|
||||
}
|
||||
else if (!s_next.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (!exp_elem.parse(pos, limit_length, expected))
|
||||
return false;
|
||||
|
||||
if (s_row.ignore(pos, expected))
|
||||
{
|
||||
if (s_rows.ignore(pos, expected))
|
||||
throw Exception("Can not use ROW and ROWS together", ErrorCodes::TOP_AND_LIMIT_TOGETHER);
|
||||
}
|
||||
else if (!s_rows.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (s_with_ties.ignore(pos, expected))
|
||||
{
|
||||
select_query->limit_with_ties = true;
|
||||
}
|
||||
else if (s_only.ignore(pos, expected))
|
||||
{
|
||||
select_query->limit_with_ties = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// This is needed for TOP expression, because it can also use WITH TIES.
|
||||
bool limit_with_ties_occured = false;
|
||||
|
||||
@ -303,8 +255,57 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
}
|
||||
else if (s_offset.ignore(pos, expected))
|
||||
{
|
||||
/// OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES}
|
||||
bool offset_with_fetch_maybe = false;
|
||||
|
||||
if (!exp_elem.parse(pos, limit_offset, expected))
|
||||
return false;
|
||||
|
||||
if (s_row.ignore(pos, expected))
|
||||
{
|
||||
if (s_rows.ignore(pos, expected))
|
||||
throw Exception("Can not use ROW and ROWS together", ErrorCodes::ROW_AND_ROWS_TOGETHER);
|
||||
offset_with_fetch_maybe = true;
|
||||
}
|
||||
else if (s_rows.ignore(pos, expected))
|
||||
{
|
||||
offset_with_fetch_maybe = true;
|
||||
}
|
||||
|
||||
if (offset_with_fetch_maybe && s_fetch.ignore(pos, expected))
|
||||
{
|
||||
/// OFFSET FETCH clause must exists with "ORDER BY"
|
||||
if (!order_expression_list)
|
||||
return false;
|
||||
|
||||
if (s_first.ignore(pos, expected))
|
||||
{
|
||||
if (s_next.ignore(pos, expected))
|
||||
throw Exception("Can not use FIRST and NEXT together", ErrorCodes::FIRST_AND_NEXT_TOGETHER);
|
||||
}
|
||||
else if (!s_next.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (!exp_elem.parse(pos, limit_length, expected))
|
||||
return false;
|
||||
|
||||
if (s_row.ignore(pos, expected))
|
||||
{
|
||||
if (s_rows.ignore(pos, expected))
|
||||
throw Exception("Can not use ROW and ROWS together", ErrorCodes::ROW_AND_ROWS_TOGETHER);
|
||||
}
|
||||
else if (!s_rows.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (s_with_ties.ignore(pos, expected))
|
||||
{
|
||||
select_query->limit_with_ties = true;
|
||||
}
|
||||
else if (s_only.ignore(pos, expected))
|
||||
{
|
||||
select_query->limit_with_ties = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Because TOP n in totally equals LIMIT n
|
||||
|
Loading…
Reference in New Issue
Block a user