mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix
fix style fix build
This commit is contained in:
parent
94e1bc05d2
commit
5f962015ca
@ -267,7 +267,7 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
ParserKeyword over("OVER");
|
||||
|
||||
bool has_all = false;
|
||||
bool has_distinct_modifier = false;
|
||||
bool has_distinct = false;
|
||||
|
||||
ASTPtr identifier;
|
||||
ASTPtr query;
|
||||
@ -281,19 +281,34 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
return false;
|
||||
++pos;
|
||||
|
||||
auto pos_after_bracket = pos;
|
||||
auto old_expected = expected;
|
||||
|
||||
if (all.ignore(pos, expected))
|
||||
has_all = true;
|
||||
|
||||
if (distinct.ignore(pos, expected))
|
||||
has_distinct_modifier = true;
|
||||
has_distinct = true;
|
||||
|
||||
if (!has_all && all.ignore(pos, expected))
|
||||
has_all = true;
|
||||
|
||||
if (has_all && has_distinct_modifier)
|
||||
if (has_all && has_distinct)
|
||||
return false;
|
||||
|
||||
if (!has_distinct_modifier)
|
||||
if (has_all || has_distinct)
|
||||
{
|
||||
/// case f(ALL), f(ALL, x), f(DISTINCT), f(DISTINCT, x), ALL and DISTINCT should be treat as identifier
|
||||
if (pos->type == TokenType::Comma || pos->type == TokenType::ClosingRoundBracket)
|
||||
{
|
||||
pos = pos_after_bracket;
|
||||
expected = old_expected;
|
||||
has_all = false;
|
||||
has_distinct = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_distinct && !has_all)
|
||||
{
|
||||
auto old_pos = pos;
|
||||
auto maybe_an_subquery = pos->type == TokenType::OpeningRoundBracket;
|
||||
@ -381,24 +396,38 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
++pos;
|
||||
|
||||
/// Parametric aggregate functions cannot have DISTINCT in parameters list.
|
||||
if (has_distinct_modifier)
|
||||
if (has_distinct)
|
||||
return false;
|
||||
|
||||
expr_list_params = expr_list_args;
|
||||
expr_list_args = nullptr;
|
||||
|
||||
pos_after_bracket = pos;
|
||||
old_expected = expected;
|
||||
|
||||
if (all.ignore(pos, expected))
|
||||
has_all = true;
|
||||
|
||||
if (distinct.ignore(pos, expected))
|
||||
has_distinct_modifier = true;
|
||||
has_distinct = true;
|
||||
|
||||
if (!has_all && all.ignore(pos, expected))
|
||||
has_all = true;
|
||||
|
||||
if (has_all && has_distinct_modifier)
|
||||
if (has_all && has_distinct)
|
||||
return false;
|
||||
|
||||
if (has_all || has_distinct)
|
||||
{
|
||||
/// case f(ALL), f(ALL, x), f(DISTINCT), f(DISTINCT, x), ALL and DISTINCT should be treat as identifier
|
||||
if (pos->type == TokenType::Comma || pos->type == TokenType::ClosingRoundBracket)
|
||||
{
|
||||
pos = pos_after_bracket;
|
||||
expected = old_expected;
|
||||
has_distinct = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!contents.parse(pos, expr_list_args, expected))
|
||||
return false;
|
||||
|
||||
@ -411,7 +440,7 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
tryGetIdentifierNameInto(identifier, function_node->name);
|
||||
|
||||
/// func(DISTINCT ...) is equivalent to funcDistinct(...)
|
||||
if (has_distinct_modifier)
|
||||
if (has_distinct)
|
||||
function_node->name += "Distinct";
|
||||
|
||||
function_node->arguments = expr_list_args;
|
||||
|
@ -92,7 +92,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
}
|
||||
}
|
||||
|
||||
/// SELECT [DISTINCT] [TOP N [WITH TIES]] expr list
|
||||
/// SELECT [ALL/DISTINCT] [TOP N [WITH TIES]] expr list
|
||||
{
|
||||
bool has_all = false;
|
||||
if (!s_select.ignore(pos, expected))
|
||||
|
@ -8,3 +8,28 @@ a
|
||||
45
|
||||
2
|
||||
1
|
||||
1
|
||||
1
|
||||
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
aaaa
|
||||
aaaaa
|
||||
aaaaaa
|
||||
aaaaaaa
|
||||
aaaaaaaa
|
||||
aaaaaaaaa
|
||||
|
||||
a
|
||||
aa
|
||||
aaa
|
||||
aaaa
|
||||
aaaaa
|
||||
aaaaaa
|
||||
aaaaaaa
|
||||
aaaaaaaa
|
||||
aaaaaaaaa
|
||||
aaaaa
|
||||
aaaaa
|
||||
aaaaa
|
||||
|
@ -9,3 +9,17 @@ SELECT sum(DISTINCT number) FROM numbers(10);
|
||||
|
||||
SELECT sum(ALL x) FROM (SELECT 1 x UNION ALL SELECT 1);
|
||||
SELECT sum(DISTINCT x) FROM (SELECT 1 x UNION ALL SELECT 1);
|
||||
|
||||
SELECT sum(ALL) FROM (SELECT 1 AS ALL);
|
||||
|
||||
SELECT sum(DISTINCT) FROM (SELECT 1 AS DISTINCT);
|
||||
|
||||
SELECT repeat('a', ALL) FROM (SELECT number AS ALL FROM numbers(10));
|
||||
|
||||
SELECT repeat('a', DISTINCT) FROM (SELECT number AS DISTINCT FROM numbers(10));
|
||||
|
||||
SELECT repeat(ALL, 5) FROM (SELECT 'a' AS ALL);
|
||||
|
||||
SELECT repeat(DISTINCT, 5) FROM (SELECT 'a' AS DISTINCT);
|
||||
|
||||
SELECT repeat(ALL, DISTINCT) FROM (SELECT 'a' AS ALL, 5 AS DISTINCT);
|
||||
|
Loading…
Reference in New Issue
Block a user