mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
fix fuzzer in query with 'WITH FILL' and 'WITH TOTALS'
This commit is contained in:
parent
82f0a5f2dd
commit
447fef702d
@ -40,10 +40,8 @@ void FillingStep::transformPipeline(QueryPipeline & pipeline, const BuildQueryPi
|
||||
{
|
||||
pipeline.addSimpleTransform([&](const Block & header, QueryPipeline::StreamType stream_type) -> ProcessorPtr
|
||||
{
|
||||
if (stream_type == QueryPipeline::StreamType::Totals)
|
||||
return nullptr;
|
||||
|
||||
return std::make_shared<FillingTransform>(header, sort_description);
|
||||
bool on_totals = stream_type == QueryPipeline::StreamType::Totals;
|
||||
return std::make_shared<FillingTransform>(header, sort_description, on_totals);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -30,12 +30,16 @@ Block FillingTransform::transformHeader(Block header, const SortDescription & so
|
||||
}
|
||||
|
||||
FillingTransform::FillingTransform(
|
||||
const Block & header_, const SortDescription & sort_description_)
|
||||
const Block & header_, const SortDescription & sort_description_, bool on_totals_)
|
||||
: ISimpleTransform(header_, transformHeader(header_, sort_description_), true)
|
||||
, sort_description(sort_description_)
|
||||
, on_totals(on_totals_)
|
||||
, filling_row(sort_description_)
|
||||
, next_row(sort_description_)
|
||||
{
|
||||
if (on_totals)
|
||||
return;
|
||||
|
||||
auto try_convert_fields = [](auto & descr, const auto & type)
|
||||
{
|
||||
auto max_type = Field::Types::Null;
|
||||
@ -106,7 +110,7 @@ FillingTransform::FillingTransform(
|
||||
|
||||
IProcessor::Status FillingTransform::prepare()
|
||||
{
|
||||
if (input.isFinished() && !output.isFinished() && !has_input && !generate_suffix)
|
||||
if (!on_totals && input.isFinished() && !output.isFinished() && !has_input && !generate_suffix)
|
||||
{
|
||||
should_insert_first = next_row < filling_row;
|
||||
|
||||
@ -126,6 +130,9 @@ IProcessor::Status FillingTransform::prepare()
|
||||
|
||||
void FillingTransform::transform(Chunk & chunk)
|
||||
{
|
||||
if (on_totals)
|
||||
return;
|
||||
|
||||
Columns old_fill_columns;
|
||||
Columns old_other_columns;
|
||||
MutableColumns res_fill_columns;
|
||||
|
@ -13,7 +13,7 @@ namespace DB
|
||||
class FillingTransform : public ISimpleTransform
|
||||
{
|
||||
public:
|
||||
FillingTransform(const Block & header_, const SortDescription & sort_description_);
|
||||
FillingTransform(const Block & header_, const SortDescription & sort_description_, bool on_totals_);
|
||||
|
||||
String getName() const override { return "FillingTransform"; }
|
||||
|
||||
@ -28,6 +28,8 @@ private:
|
||||
void setResultColumns(Chunk & chunk, MutableColumns & fill_columns, MutableColumns & other_columns) const;
|
||||
|
||||
const SortDescription sort_description; /// Contains only rows with WITH FILL.
|
||||
const bool on_totals; /// FillingTransform does nothing on totals.
|
||||
|
||||
FillingRow filling_row; /// Current row, which is used to fill gaps.
|
||||
FillingRow next_row; /// Row to which we need to generate filling rows.
|
||||
|
||||
|
@ -1,8 +1,20 @@
|
||||
20 0
|
||||
19 0
|
||||
18 0
|
||||
17 0
|
||||
16 0
|
||||
15 0
|
||||
14 0
|
||||
13 0
|
||||
12 0
|
||||
11 0
|
||||
10 0
|
||||
9 0
|
||||
8 0
|
||||
7 7
|
||||
6 0
|
||||
5 0
|
||||
4 4
|
||||
3 0
|
||||
2 0
|
||||
1 1
|
||||
|
||||
0 12
|
||||
15 0
|
||||
14 0
|
||||
13 0
|
||||
|
@ -5,4 +5,13 @@ FROM numbers(10)
|
||||
WHERE number % 3 = 1
|
||||
GROUP BY number
|
||||
WITH TOTALS
|
||||
ORDER BY number DESC WITH FILL FROM 20;
|
||||
ORDER BY number DESC WITH FILL FROM 15;
|
||||
|
||||
SELECT
|
||||
number,
|
||||
sum(number)
|
||||
FROM numbers(10)
|
||||
WHERE number % 3 = 1
|
||||
GROUP BY number
|
||||
WITH TOTALS
|
||||
ORDER BY 10, number DESC WITH FILL FROM 15;
|
||||
|
Loading…
Reference in New Issue
Block a user