Skip to content

Commit 5f4e835

Browse files
Merge pull request ClickHouse#90619 from ClickHouse/backport/25.8/90375
Backport ClickHouse#90375 to 25.8: Fix prewhere on non-existing JSON path with index_granularity_bytes=0
2 parents 5d4b212 + 5a410dc commit 5f4e835

6 files changed

+28
-4
lines changed

src/DataTypes/Serializations/SerializationObjectSharedDataPath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void SerializationObjectSharedDataPath::deserializeBinaryBulkWithMultipleStreams
250250
/// Check if we don't have any paths in shared data in current range.
251251
const auto & offsets = assert_cast<const ColumnArray &>(*map_column).getOffsets();
252252
if (offsets.back() == offsets[ssize_t(map_column_offset) - 1])
253-
dynamic_column->insertManyDefaults(limit);
253+
dynamic_column->insertManyDefaults(num_read_rows);
254254
else
255255
ColumnObject::fillPathColumnFromSharedData(*dynamic_column, path, map_column, map_column_offset, map_column->size());
256256

src/DataTypes/Serializations/SerializationVariantElementNullMap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ void SerializationVariantElementNullMap::deserializeBinaryBulkWithMultipleStream
163163
/// Check if there are no such variant in read range.
164164
if (variant_limit && *variant_limit == 0)
165165
{
166-
data.resize_fill(data.size() + limit, 1);
166+
data.resize_fill(data.size() + num_read_discriminators, 1);
167167
}
168168
/// Check if there is only our variant in read range.
169-
else if (variant_limit && *variant_limit == limit)
169+
else if (variant_limit && *variant_limit == num_read_discriminators)
170170
{
171-
data.resize_fill(data.size() + limit, 0);
171+
data.resize_fill(data.size() + num_read_discriminators, 0);
172172
}
173173
/// Iterate through new discriminators to calculate the null map of our variant.
174174
else
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
DROP TABLE IF EXISTS test;
2+
3+
CREATE TABLE test (
4+
s String,
5+
json JSON
6+
)
7+
ENGINE = MergeTree
8+
ORDER BY (s)
9+
SETTINGS index_granularity = 2, index_granularity_bytes = 0, min_rows_for_wide_part=0, min_bytes_for_wide_part=0;
10+
11+
INSERT INTO test SELECT 'a', '{}' FROM numbers(1);
12+
13+
SELECT count() FROM test WHERE s = 'a' AND json.a IS NULL;
14+
15+
DROP TABLE test;
16+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
drop table if exists test;
2+
create table test (s Int128, v Variant(UUID, Int128)) engine=MergeTree order by s settings index_granularity = 2, index_granularity_bytes = 0, min_rows_for_wide_part=0, min_bytes_for_wide_part=0;
3+
insert into test select 42::Int128, 42::Int128;
4+
select v from test prewhere 1;
5+
drop table test;
6+

0 commit comments

Comments
 (0)