Merge pull request #45617 from ClickHouse/fix-bfngram-index

Correctly check types when using N-gram bloom filter index
This commit is contained in:
Antonio Andelic 2023-01-26 09:05:56 +01:00 committed by GitHub
commit 6fe9e9a67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -468,6 +468,10 @@ bool MergeTreeConditionFullText::traverseTreeEquals(
{
key_column_num = map_keys_key_column_num;
key_exists = true;
auto const_data_type = WhichDataType(const_type);
if (!const_data_type.isStringOrFixedString() && !const_data_type.isArray())
return false;
}
else
{

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS 02538_bf_ngrambf_map_values_test;
CREATE TABLE 02538_bf_ngrambf_map_values_test (`row_id` Int128, `map` Map(String, String), `map_fixed` Map(FixedString(2), String),
INDEX map_values_ngrambf mapKeys(map) TYPE ngrambf_v1(4, 256, 2, 0) GRANULARITY 1,
INDEX map_fixed_values_ngrambf mapKeys(map_fixed) TYPE ngrambf_v1(4, 256, 2, 0) GRANULARITY 1)
ENGINE = MergeTree
ORDER BY row_id
SETTINGS index_granularity = 1;
INSERT INTO 02538_bf_ngrambf_map_values_test VALUES (1, {'a': 'a'}, {'b': 'b'});
SELECT * FROM 02538_bf_ngrambf_map_values_test PREWHERE (map['']) = 'V2V\0V2V2V2V2V2V2' WHERE (map[NULL]) = 'V2V\0V2V2V2V2V2V2V2V\0V2V2V2V2V2V2V2V\0V2V2V2V2V2V2V2V\0V2V2V2V2V2V2' SETTINGS force_data_skipping_indices = 'map_values_ngrambf';
DROP TABLE 02538_bf_ngrambf_map_values_test;