Repository navigation
Fix ColumnConst not materialized before squashing - #97019
Conversation
| /// since `IColumn::isSparse` is not recursive but sparse column can be inside a tuple, for example. | ||
| have_same_serialization[j] &= columns[j]->structureEquals(*mutable_columns[j]); | ||
|
|
||
| /// ColumnConst can have different values, only squash if different value |
There was a problem hiding this comment.
Not squashing is not the right solution. The right solution is materializing constants.
There was a problem hiding this comment.
Ok I updated to just materializing ColumnConst.
There was a problem hiding this comment.
Looks like before this, the materialize happens outside of squashing, and removing the materialize introduce this bug: 3acbbe7
| /// ignores the source value and just increments the row count | ||
| if (isColumnConst(*mutable_columns[i])) | ||
| { | ||
| mutable_columns[i] = mutable_columns[i]->convertToFullColumnIfConst()->assumeMutable(); |
There was a problem hiding this comment.
assumeMutable() is error-prone, use std::move(...->mutate()) - see examples in the code.
There was a problem hiding this comment.
Shouldn't mutable_columns be already materialized here?
There was a problem hiding this comment.
assumeMutable() is error-prone, use std::move(...->mutate()) - see examples in the code.
I changed it to IColumn::mutate similar to this (I also changed the line below, I was following it):
Shouldn't mutable_columns be already materialized here?
No, if I remove this line, the test fails.
| for (auto & column : source_columns_list[i]) | ||
| column = column->convertToFullColumnIfConst(); | ||
| } | ||
| else if (!have_same_serialization[i]) |
There was a problem hiding this comment.
I wanted to suggest to change else if to a separate if. Since logically, the conditions isColumnConst and !have_same_serialization do not exclude each other.
| SELECT s, x FROM a LEFT JOIN numbers(30) num1 ON a.x = num1.number | ||
| UNION ALL | ||
| SELECT s, x FROM b LEFT JOIN numbers(10) num2 ON b.x = num2.number | ||
| UNION ALL | ||
| SELECT s, x FROM c LEFT JOIN numbers(20) num3 ON c.x = num3.number | ||
| UNION ALL | ||
| SELECT s, x FROM d LEFT JOIN numbers(15) num4 ON d.x = num4.number; |
There was a problem hiding this comment.
Let's change LEFT JOIN to JOIN here, so that we also test a different semantic.
|
Are these failures related to my change? |
|
I don't think so. They used to fail a few days ago, but were fixed recently. Please try merging with master so that the most recent updates are added to your branch. |
|
We need help from @Fgrtue to understand why we can have constants with different values, why the materialization outside of squashing no longer works, and to fix the root cause. |
|
Right, in order restate the roots of the issue, here is the summary:
|
Backport #97019 to 26.1: Fix ColumnConst not materialized before squashing
Backport #97019 to 25.11: Fix ColumnConst not materialized before squashing
Backport #97019 to 25.12: Fix ColumnConst not materialized before squashing
Summary
Fixes #95537.
ColumnConstshould be materialized before squashing, otherwiseColumnConst('a', 100)andColumnConst('b', 90)get squashed toColumnConst('a', 190). This is what was done before the regression.Changelog category (leave one):
Changelog entry (a [user-readable short description]
Fix ColumnConst not materialized before squashing
Version info
26.2.1.108426.1.4.17,25.12.7.18,25.11.10.19