mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
add new syntax
This commit is contained in:
parent
43951e4879
commit
31bf960bfe
@ -37,8 +37,8 @@ Block CubeBlockInputStream::getHeader() const
|
||||
Block CubeBlockInputStream::readImpl()
|
||||
{
|
||||
/** After reading a block from input stream,
|
||||
* we will subsequently roll it up on next iterations of 'readImpl'
|
||||
* by zeroing out every column one-by-one and re-merging a block.
|
||||
* we will calculate all subsets of columns on next iterations of readImpl
|
||||
* by zeroing columns at positions, where bits are zero in current bitmask.
|
||||
*/
|
||||
|
||||
if (mask)
|
||||
|
@ -13,7 +13,7 @@ class ExpressionActions;
|
||||
|
||||
|
||||
/** Takes blocks after grouping, with non-finalized aggregate functions.
|
||||
* Calculates subtotals and grand totals values for a set of columns.
|
||||
* Calculates all subsets of columns and aggreagetes over them.
|
||||
*/
|
||||
class CubeBlockInputStream : public IProfilingBlockInputStream
|
||||
{
|
||||
|
@ -106,6 +106,9 @@ void ASTSelectQuery::formatImpl(const FormatSettings & s, FormatState & state, F
|
||||
if (group_by_with_rollup)
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH ROLLUP" << (s.hilite ? hilite_none : "");
|
||||
|
||||
if (group_by_with_cube)
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH CUBE" << (s.hilite ? hilite_none : "");
|
||||
|
||||
if (group_by_with_totals)
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH TOTALS" << (s.hilite ? hilite_none : "");
|
||||
|
||||
|
@ -131,11 +131,13 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
return false;
|
||||
}
|
||||
|
||||
/// WITH ROLLUP or TOTALS
|
||||
/// WITH ROLLUP, CUBE or TOTALS
|
||||
if (s_with.ignore(pos, expected))
|
||||
{
|
||||
if (s_rollup.ignore(pos, expected))
|
||||
select_query->group_by_with_rollup = true;
|
||||
else if (s_cube.ignore(pos, expected))
|
||||
select_query->group_by_with_cube = true;
|
||||
else if (s_totals.ignore(pos, expected))
|
||||
select_query->group_by_with_totals = true;
|
||||
else
|
||||
|
@ -21,3 +21,19 @@ b 2 35 2
|
||||
120 8
|
||||
a 70 4
|
||||
b 50 4
|
||||
0 120 8
|
||||
a 0 70 4
|
||||
a 1 25 2
|
||||
a 2 45 2
|
||||
b 0 50 4
|
||||
b 1 15 2
|
||||
b 2 35 2
|
||||
0 120 8
|
||||
a 0 70 4
|
||||
a 1 25 2
|
||||
a 2 45 2
|
||||
b 0 50 4
|
||||
b 1 15 2
|
||||
b 2 35 2
|
||||
|
||||
0 120 8
|
@ -15,3 +15,7 @@ SELECT a, b, sum(s), count() from test.rollup GROUP BY CUBE(a, b) ORDER BY a, b;
|
||||
SELECT a, b, sum(s), count() from test.rollup GROUP BY CUBE(a, b) WITH TOTALS ORDER BY a, b;
|
||||
|
||||
SELECT a, sum(s), count() from test.rollup GROUP BY CUBE(a) ORDER BY a;
|
||||
|
||||
SELECT a, b, sum(s), count() from test.rollup GROUP BY a, b WITH ROLLUP ORDER BY a;
|
||||
|
||||
SELECT a, b, sum(s), count() from test.rollup GROUP BY a, b WITH ROLLUP WITH TOTALS ORDER BY a;
|
Loading…
Reference in New Issue
Block a user