Merge pull request #30888 from CurtizJ/with-fill-no-rows

Fix WITH FILL with set TO and FROM and no rows in result set
This commit is contained in:
alexey-milovidov 2021-10-31 12:29:07 +03:00 committed by GitHub
commit 0ffb580515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;