mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Fixed bloom_filter bug that counting error for Array(Nullable(String)).
This commit is contained in:
parent
9534eb32a0
commit
fe7ae014d8
@ -85,8 +85,15 @@ struct BloomFilterHash
|
|||||||
throw Exception("Unexpected type " + data_type->getName() + " of bloom filter index.", ErrorCodes::LOGICAL_ERROR);
|
throw Exception("Unexpected type " + data_type->getName() + " of bloom filter index.", ErrorCodes::LOGICAL_ERROR);
|
||||||
|
|
||||||
const auto & offsets = array_col->getOffsets();
|
const auto & offsets = array_col->getOffsets();
|
||||||
size_t offset = (pos == 0) ? 0 : offsets[pos - 1];
|
limit = offsets[pos + limit - 1] - ((pos == 0) ? 0 : offsets[pos - 1]);
|
||||||
limit = std::max(array_col->getData().size() - offset, limit);
|
|
||||||
|
if (limit == 0)
|
||||||
|
{
|
||||||
|
auto index_column = ColumnUInt64::create(1);
|
||||||
|
ColumnUInt64::Container & index_column_vec = index_column->getData();
|
||||||
|
index_column_vec[0] = 0;
|
||||||
|
return index_column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ColumnPtr actual_col = BloomFilter::getPrimitiveColumn(column);
|
const ColumnPtr actual_col = BloomFilter::getPrimitiveColumn(column);
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
7
|
||||||
|
1
|
||||||
|
2
|
||||||
|
1
|
||||||
|
0
|
@ -0,0 +1,18 @@
|
|||||||
|
SET allow_experimental_data_skipping_indices = 1;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test.bloom_filter_null_array;
|
||||||
|
|
||||||
|
CREATE TABLE test.bloom_filter_null_array (v Array(LowCardinality(Nullable(String))), INDEX idx v TYPE bloom_filter(0.1) GRANULARITY 1) ENGINE = MergeTree() ORDER BY v;
|
||||||
|
|
||||||
|
INSERT INTO test.bloom_filter_null_array VALUES ([]);
|
||||||
|
INSERT INTO test.bloom_filter_null_array VALUES (['1', '2']) ([]) ([]);
|
||||||
|
INSERT INTO test.bloom_filter_null_array VALUES ([]) ([]) (['2', '3']);
|
||||||
|
|
||||||
|
SELECT COUNT() FROM test.bloom_filter_null_array;
|
||||||
|
SELECT COUNT() FROM test.bloom_filter_null_array WHERE has(v, '1');
|
||||||
|
SELECT COUNT() FROM test.bloom_filter_null_array WHERE has(v, '2');
|
||||||
|
SELECT COUNT() FROM test.bloom_filter_null_array WHERE has(v, '3');
|
||||||
|
SELECT COUNT() FROM test.bloom_filter_null_array WHERE has(v, '4');
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS test.bloom_filter_null_array;
|
Loading…
Reference in New Issue
Block a user