add rollup to formatted query

This commit is contained in:
CurtizJ 2018-09-05 19:23:28 +03:00
parent 0ad5793681
commit 472adf4ab9
4 changed files with 9 additions and 7 deletions

View File

@ -28,7 +28,7 @@ RollupBlockInputStream::RollupBlockInputStream(
keys(params_.keys)
{
children.push_back(input_);
Aggregator::CancellationHook hook = [&]() { return this->isCancelled(); };
Aggregator::CancellationHook hook = [this]() { return this->isCancelled(); };
aggregator.setCancellationHook(hook);
}
@ -57,12 +57,12 @@ Block RollupBlockInputStream::readImpl()
return finalized;
}
current_block = children[0]->read();
Block block = children[0]->read();
current_key = keys.size() - 1;
rollup_block = current_block;
finalize(current_block);
rollup_block = block;
finalize(block);
return current_block;
return block;
}
}

View File

@ -35,7 +35,6 @@ private:
Aggregator aggregator;
ColumnNumbers keys;
ssize_t current_key = -1;
Block current_block;
Block rollup_block;
};

View File

@ -706,7 +706,7 @@ void InterpreterSelectQuery::executeFetchColumns(
max_streams = settings.max_distributed_connections;
}
size_t max_block_size = settings.max_block_size;
size_t max_block_size = settings.max_block_size;
if (!max_block_size)
throw Exception("Setting 'max_block_size' cannot be zero", ErrorCodes::PARAMETER_OUT_OF_BOUND);

View File

@ -103,6 +103,9 @@ void ASTSelectQuery::formatImpl(const FormatSettings & s, FormatState & state, F
: typeid_cast<const ASTExpressionList &>(*group_expression_list).formatImplMultiline(s, state, frame);
}
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_totals)
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << (s.one_line ? "" : " ") << "WITH TOTALS" << (s.hilite ? hilite_none : "");