mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
fix WITH FILL with set TO and FROM and no rows in result set
This commit is contained in:
parent
059c1ebf36
commit
5fe4bcd22e
@ -117,12 +117,12 @@ IProcessor::Status FillingTransform::prepare()
|
|||||||
{
|
{
|
||||||
if (!on_totals && 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;
|
should_insert_first = next_row < filling_row || first;
|
||||||
|
|
||||||
for (size_t i = 0, size = filling_row.size(); i < size; ++i)
|
for (size_t i = 0, size = filling_row.size(); i < size; ++i)
|
||||||
next_row[i] = filling_row.getFillDescription(i).fill_to;
|
next_row[i] = filling_row.getFillDescription(i).fill_to;
|
||||||
|
|
||||||
if (filling_row < next_row)
|
if (first || filling_row < next_row)
|
||||||
{
|
{
|
||||||
generate_suffix = true;
|
generate_suffix = true;
|
||||||
return Status::Ready;
|
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_fill_columns, res_fill_columns, fill_column_positions);
|
||||||
init_columns_by_positions(empty_columns, old_other_columns, res_other_columns, other_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)
|
if (should_insert_first && filling_row < next_row)
|
||||||
insertFromFillingRow(res_fill_columns, res_other_columns, filling_row);
|
insertFromFillingRow(res_fill_columns, res_other_columns, filling_row);
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
2019 0
|
||||||
|
2020 0
|
||||||
|
2021 0
|
||||||
|
2022 0
|
19
tests/queries/0_stateless/02111_with_fill_no_rows.sql
Normal file
19
tests/queries/0_stateless/02111_with_fill_no_rows.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user