mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
update syntax and test
This commit is contained in:
parent
b48a144d78
commit
0e28195e7a
@ -1,5 +1,4 @@
|
||||
#include <memory>
|
||||
#include <Poco/String.h>
|
||||
#include <Parsers/ASTSelectQuery.h>
|
||||
#include <Parsers/ASTIdentifier.h>
|
||||
#include <Parsers/IParserBase.h>
|
||||
@ -134,22 +133,24 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
const String identifier_totals = "identifier_totals";
|
||||
const String identifier_rollup = "identifier_rollup";
|
||||
|
||||
/// WITH TOTALS and/or ROLLUP
|
||||
/// WITH ROLLUP
|
||||
if (s_with.ignore(pos, expected))
|
||||
{
|
||||
if (!exp_list.parse(pos, totals_and_rollup_list, expected))
|
||||
if (s_rollup.ignore(pos, expected))
|
||||
select_query->group_by_with_rollup = true;
|
||||
else if (s_totals.ignore(pos, expected))
|
||||
select_query->group_by_with_totals = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// WITH TOTALS
|
||||
if (s_with.ignore(pos, expected))
|
||||
{
|
||||
if (select_query->group_by_with_totals || !s_totals.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
for (const auto & child : totals_and_rollup_list->children)
|
||||
{
|
||||
String id = Poco::toLower(child->getID());
|
||||
if (id == identifier_totals)
|
||||
select_query->group_by_with_totals = true;
|
||||
else if (id == identifier_rollup)
|
||||
select_query->group_by_with_rollup = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
select_query->group_by_with_totals = true;
|
||||
}
|
||||
|
||||
/// HAVING expr
|
||||
|
@ -17,3 +17,11 @@ b 2 35 2
|
||||
120 8
|
||||
a 70 4
|
||||
b 50 4
|
||||
120 8
|
||||
a 70 4
|
||||
b 50 4
|
||||
120 8
|
||||
a 70 4
|
||||
b 50 4
|
||||
|
||||
120 8
|
||||
|
@ -15,3 +15,7 @@ SELECT a, b, sum(s), count() from test.rollup GROUP BY ROLLUP(a, b) ORDER BY a,
|
||||
SELECT a, b, sum(s), count() from test.rollup GROUP BY ROLLUP(a, b) WITH TOTALS ORDER BY a, b;
|
||||
|
||||
SELECT a, sum(s), count() from test.rollup GROUP BY ROLLUP(a) ORDER BY a;
|
||||
|
||||
SELECT a, sum(s), count() from test.rollup GROUP BY a WITH ROLLUP ORDER BY a;
|
||||
|
||||
SELECT a, sum(s), count() from test.rollup GROUP BY a WITH ROLLUP WITH TOTALS ORDER BY a;
|
||||
|
Loading…
Reference in New Issue
Block a user