fix WITH FILL with set TO and FROM and no rows in result set

This commit is contained in:
Anton Popov 2021-10-30 21:33:31 +03:00
parent 059c1ebf36
commit 5fe4bcd22e
3 changed files with 28 additions and 2 deletions

View File

@ -117,12 +117,12 @@ IProcessor::Status FillingTransform::prepare()
{
if (!on_totals && input.isFinished() && !output.isFinished() && !has_input && !generate_suffix)
{
should_insert_first = next_row < filling_row;
should_insert_first = next_row < filling_row || first;
for (size_t i = 0, size = filling_row.size(); i < size; ++i)
next_row[i] = filling_row.getFillDescription(i).fill_to;
if (filling_row < next_row)
if (first || filling_row < next_row)
{
generate_suffix = true;
return Status::Ready;
@ -160,6 +160,9 @@ void FillingTransform::transform(Chunk & chunk)
init_columns_by_positions(empty_columns, old_fill_columns, res_fill_columns, fill_column_positions);
init_columns_by_positions(empty_columns, old_other_columns, res_other_columns, other_column_positions);
if (first)
filling_row.initFromDefaults();
if (should_insert_first && filling_row < next_row)
insertFromFillingRow(res_fill_columns, res_other_columns, filling_row);

View File

@ -0,0 +1,4 @@
2019 0
2020 0
2021 0
2022 0

View File

@ -0,0 +1,19 @@
SELECT toYear(d) AS y, count()
FROM ( SELECT today() AS d WHERE 0)
GROUP BY y
ORDER BY y ASC WITH FILL FROM 2019 TO 2023;
SELECT toYear(d) AS y, count()
FROM ( SELECT today() AS d WHERE 0)
GROUP BY y
ORDER BY y ASC WITH FILL FROM 2019;
SELECT toYear(d) AS y, count()
FROM ( SELECT today() AS d WHERE 0)
GROUP BY y
ORDER BY y ASC WITH FILL TO 2023;
SELECT toYear(d) AS y, count()
FROM ( SELECT today() AS d WHERE 0)
GROUP BY y
ORDER BY y ASC WITH FILL;