mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
MergeTreeIndexConditionBloomFilter updated for Map data type
This commit is contained in:
parent
8962672e59
commit
15c9315ea1
@ -129,10 +129,10 @@ struct BloomFilterHash
|
||||
const auto * map_col = typeid_cast<const ColumnMap *>(column.get());
|
||||
const auto & keys_data = map_col->getNestedData().getColumn(0);
|
||||
if (checkAndGetColumn<ColumnNullable>(keys_data))
|
||||
throw Exception("Unexpected key type " + data_type->getName() + " of bloom filter index for map.", ErrorCodes::BAD_ARGUMENTS);
|
||||
throw Exception("Unexpected key type " + data_type->getName() + " of bloom filter index.", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
const auto & offsets = map_col->getNestedColumn().getOffsets();
|
||||
limit = offsets[pos + limit - 1] - offsets[pos - 1];
|
||||
limit = offsets[pos + limit - 1] - offsets[pos - 1]; /// PaddedPODArray allows access on index -1.
|
||||
pos = offsets[pos - 1];
|
||||
|
||||
if (limit == 0)
|
||||
|
@ -189,7 +189,6 @@ bool MergeTreeIndexConditionBloomFilter::mayBeTrueOnGranule(const MergeTreeIndex
|
||||
const auto & filter = filters[query_index_hash.first];
|
||||
const ColumnPtr & hash_column = query_index_hash.second;
|
||||
|
||||
|
||||
match_rows = maybeTrueOnBloomFilter(&*hash_column,
|
||||
filter,
|
||||
hash_functions,
|
||||
@ -513,7 +512,7 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
|
||||
if (function->name == "arrayElement")
|
||||
{
|
||||
auto & col_name = assert_cast<ASTIdentifier *>(function->arguments.get()->children[0].get())->name();
|
||||
const auto & col_name = assert_cast<ASTIdentifier *>(function->arguments.get()->children[0].get())->name();
|
||||
|
||||
if (header.has(col_name))
|
||||
{
|
||||
@ -523,12 +522,20 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals(
|
||||
if (map_type)
|
||||
{
|
||||
out.function = function_name == "equals" ? RPNElement::FUNCTION_EQUALS : RPNElement::FUNCTION_NOT_EQUALS;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(index_type);
|
||||
/// TODO :: Here, we assume the second argument of arrayElement is const string, need to support column and other data types.
|
||||
auto & element_key = assert_cast<ASTIdentifier *>(function->arguments.get()->children[1].get())->name();
|
||||
Field element_key_field = element_key;
|
||||
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), element_key_field)));
|
||||
auto & argument = function->arguments.get()->children[1];
|
||||
|
||||
if (const auto * literal = argument->as<ASTLiteral>())
|
||||
{
|
||||
auto element_key = literal->value;
|
||||
const DataTypePtr actual_type = BloomFilter::getPrimitiveType(index_type);
|
||||
out.predicate.emplace_back(std::make_pair(position, BloomFilterHash::hashWithField(actual_type.get(), element_key)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user