Skip to content

Commit 6ceca1f

Browse files
Backport #72226 to 24.11: Fix assert failure in SimpleSquashingChunksTransform
1 parent e49ef4f commit 6ceca1f

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/Interpreters/Squashing.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,19 @@ Chunk Squashing::squash(std::vector<Chunk> && input_chunks, Chunk::ChunkInfoColl
145145
auto columns = input_chunks[i].detachColumns();
146146
for (size_t j = 0; j != num_columns; ++j)
147147
{
148-
have_same_serialization[j] &= ISerialization::getKind(*columns[j]) == ISerialization::getKind(*mutable_columns[j]);
148+
/// IColumn::structureEquals is not implemented for deprecated object type, ignore it and always convert to non-sparse.
149+
bool has_object_deprecated = columns[j]->getDataType() == TypeIndex::ObjectDeprecated ||
150+
mutable_columns[j]->getDataType() == TypeIndex::ObjectDeprecated;
151+
auto has_object_deprecated_lambda = [&has_object_deprecated](const auto & subcolumn)
152+
{
153+
has_object_deprecated = has_object_deprecated || subcolumn.getDataType() == TypeIndex::ObjectDeprecated;
154+
};
155+
columns[j]->forEachSubcolumnRecursively(has_object_deprecated_lambda);
156+
mutable_columns[j]->forEachSubcolumnRecursively(has_object_deprecated_lambda);
157+
158+
/// Need to check if there are any sparse columns in subcolumns,
159+
/// since `IColumn::isSparse` is not recursive but sparse column can be inside a tuple, for example.
160+
have_same_serialization[j] &= !has_object_deprecated && columns[j]->structureEquals(*mutable_columns[j]);
149161
source_columns_list[j].emplace_back(std::move(columns[j]));
150162
}
151163
}

tests/queries/0_stateless/03274_squashing_transform_sparse_bug.reference

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
DROP TABLE IF EXISTS t0;
3+
DROP TABLE IF EXISTS t1;
4+
5+
SET max_insert_block_size = 1;
6+
SET min_insert_block_size_rows = 1;
7+
SET min_insert_block_size_bytes = 1;
8+
9+
CREATE TABLE t0 (x UInt64, y Tuple(UInt64, UInt64) ) ENGINE = MergeTree ORDER BY x SETTINGS ratio_of_defaults_for_sparse_serialization = 0.5;
10+
SYSTEM STOP MERGES t0;
11+
INSERT INTO t0 SELECT if(number % 2 = 0, 0, number) as x, (x, 0) from numbers(200) SETTINGS max_block_size = 1;
12+
13+
CREATE TABLE t1 (x UInt64, y Tuple(UInt64, UInt64) ) ENGINE = MergeTree ORDER BY x;
14+
15+
SET min_joined_block_size_bytes = 100;
16+
17+
SET join_algorithm = 'parallel_hash';
18+
SELECT sum(ignore(*)) FROM t0 a FULL JOIN t1 b ON a.x = b.x FORMAT Null;

0 commit comments

Comments
 (0)