mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
fix assertion in bloom filter index
This commit is contained in:
parent
2054582a06
commit
2f423071f2
@ -542,7 +542,10 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
{
|
||||
out.function = RPNElement::FUNCTION_HAS;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(array_type->getNestedType());
|
||||
Field converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
auto converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
if (converted_field.isNull())
|
||||
return false;
|
||||
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), converted_field)));
|
||||
}
|
||||
}
|
||||
@ -565,7 +568,11 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
if ((f.isNull() && !is_nullable) || f.isDecimal(f.getType()))
|
||||
return false;
|
||||
|
||||
mutable_column->insert(convertFieldToType(f, *actual_type, value_type.get()));
|
||||
auto converted = convertFieldToType(f, *actual_type);
|
||||
if (converted.isNull())
|
||||
return false;
|
||||
|
||||
mutable_column->insert(converted);
|
||||
}
|
||||
|
||||
column = std::move(mutable_column);
|
||||
@ -583,7 +590,10 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
|
||||
out.function = function_name == "equals" ? RPNElement::FUNCTION_EQUALS : RPNElement::FUNCTION_NOT_EQUALS;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(index_type);
|
||||
Field converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
auto converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
if (converted_field.isNull())
|
||||
return false;
|
||||
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), converted_field)));
|
||||
}
|
||||
|
||||
@ -611,9 +621,11 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
|
||||
out.function = RPNElement::FUNCTION_HAS;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(array_type->getNestedType());
|
||||
Field converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), converted_field)));
|
||||
auto converted_field = convertFieldToType(value_field, *actual_type, value_type.get());
|
||||
if (converted_field.isNull())
|
||||
return false;
|
||||
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), converted_field)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
28
tests/queries/0_stateless/02456_bloom_filter_assert.sql.j2
Normal file
28
tests/queries/0_stateless/02456_bloom_filter_assert.sql.j2
Normal file
@ -0,0 +1,28 @@
|
||||
{% for type in ["Int8", "Int16", "Int32", "Int64", 'UInt8', 'UInt16', 'UInt32'] -%}
|
||||
|
||||
DROP TABLE IF EXISTS bftest__fuzz_21;
|
||||
|
||||
CREATE TABLE bftest__fuzz_21
|
||||
(
|
||||
`k` Int64,
|
||||
`x` Array({{ type }}),
|
||||
INDEX ix1 x TYPE bloom_filter GRANULARITY 3
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY k;
|
||||
|
||||
INSERT INTO bftest__fuzz_21 (k, x) SELECT
|
||||
number,
|
||||
arrayMap(i -> (rand64() % 565656), range(10))
|
||||
FROM numbers(1000);
|
||||
|
||||
{% if 'UInt' in type -%}
|
||||
SELECT count() FROM bftest__fuzz_21 WHERE hasAll(x, [42, -42]) SETTINGS use_skip_indexes=1;
|
||||
SELECT count() FROM bftest__fuzz_21 WHERE hasAll(x, [42, -42]) SETTINGS use_skip_indexes=1, force_data_skipping_indices='ix1'; -- { serverError INDEX_NOT_USED }
|
||||
{% else -%}
|
||||
SELECT count() FROM bftest__fuzz_21 WHERE hasAll(x, [42, -42]) SETTINGS use_skip_indexes=1, force_data_skipping_indices='ix1';
|
||||
{% endif -%}
|
||||
|
||||
DROP TABLE IF EXISTS bftest__fuzz_21;
|
||||
|
||||
{% endfor -%}
|
Loading…
Reference in New Issue
Block a user