diff --git a/src/Storages/MergeTree/MergeTreeIndexSet.cpp b/src/Storages/MergeTree/MergeTreeIndexSet.cpp index fa242fccbc1..497520a94f2 100644 --- a/src/Storages/MergeTree/MergeTreeIndexSet.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexSet.cpp @@ -100,7 +100,10 @@ void MergeTreeIndexGranuleSet::deserializeBinary(ReadBuffer & istr, MergeTreeInd size_t rows_to_read = field_rows.safeGet(); if (rows_to_read == 0) + { + block.clear(); return; + } size_t num_columns = block.columns(); diff --git a/tests/queries/0_stateless/03246_skipping_index_70108.reference b/tests/queries/0_stateless/03246_skipping_index_70108.reference new file mode 100644 index 00000000000..463ab3429c6 --- /dev/null +++ b/tests/queries/0_stateless/03246_skipping_index_70108.reference @@ -0,0 +1,2 @@ +22 +22 diff --git a/tests/queries/0_stateless/03246_skipping_index_70108.sh b/tests/queries/0_stateless/03246_skipping_index_70108.sh new file mode 100755 index 00000000000..1a5a6631825 --- /dev/null +++ b/tests/queries/0_stateless/03246_skipping_index_70108.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +$CLICKHOUSE_LOCAL -m " + CREATE TABLE t + ( + c0 UInt64, + c1 String, + INDEX c1_idx c1 TYPE set(666) GRANULARITY 1 + ) + ENGINE = MergeTree + ORDER BY c0; + INSERT INTO t SELECT * FROM file('$CURDIR/data_i70108/repro.tsv.zstd'); + +SELECT count() FROM t WHERE c1 = 'dedenk1d4q' SETTINGS use_skip_indexes=1; +SELECT count() FROM t WHERE c1 = 'dedenk1d4q' SETTINGS use_skip_indexes=0; +" diff --git a/tests/queries/0_stateless/data_i70108/repro.tsv.zstd b/tests/queries/0_stateless/data_i70108/repro.tsv.zstd new file mode 100644 index 00000000000..1690a8339cc Binary files /dev/null and b/tests/queries/0_stateless/data_i70108/repro.tsv.zstd differ