MCPcopy Create free account
hub / github.com/ByConity/ByConity / isArraySetCheck

Method isArraySetCheck

src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:298–355  ·  view source on GitHub ↗

A expression is arraySetCheck if 1. single arraySetCheck function with column argument is a BLOOM column 2. not arraySetCheck function

Source from the content-addressed store, hash-verified

296// 1. single arraySetCheck function with column argument is a BLOOM column
297// 2. not arraySetCheck function
298bool MergeTreeWhereOptimizer::isArraySetCheck(const ASTPtr & condition, bool) const
299{
300 if (!condition)
301 return false;
302
303 const auto * const function = typeid_cast<const ASTFunction *>(condition.get());
304
305 if (function)
306 {
307 if (BitmapIndexHelper::isArraySetFunctions(function->name))
308 {
309 size_t arg_size = function->arguments->children.size();
310 if (arg_size % 2)
311 throw Exception("Wrong number of arguments of arraySetCheck", ErrorCodes::LOGICAL_ERROR);
312
313 for (size_t i = 0; i < arg_size; i += 2)
314 {
315 auto * left_arg = function->arguments->children.at(i).get();
316 auto * right_arg = function->arguments->children.at(i + 1).get();
317 auto * identifier = left_arg->as<ASTIdentifier>();
318 if (!identifier || right_arg->as<ASTIdentifier>())
319 return false;
320
321 String identifier_name = identifier->getColumnName();
322 if (isMapImplicitKey(identifier_name))
323 identifier_name = parseMapNameFromImplicitFileName(identifier_name);
324
325 auto columns = metadata_snapshot->getColumns();
326 if (!columns.has(identifier_name))
327 return false;
328
329 // unlikely
330 {
331 // Cannot handle column like 'map.key'
332 auto [maybe_reserved_map_keys, name_without_suffix] = mayBeMapKVReservedKeys(identifier_name);
333 if (maybe_reserved_map_keys)
334 {
335 if (!columns.has(name_without_suffix))
336 return false;
337
338 const ColumnDescription & column = columns.get(name_without_suffix);
339 if (column.type->isMap())
340 return false;
341 }
342 }
343
344 const ColumnDescription & column = columns.get(identifier_name);
345
346 if (!column.type->isBitmapIndex() && !column.type->isSegmentBitmapIndex())
347 return false;
348 }
349
350 return true;
351 }
352 }
353
354 return false;
355}

Callers

nothing calls this directly

Calls 14

isArraySetFunctionsFunction · 0.85
isMapImplicitKeyFunction · 0.85
mayBeMapKVReservedKeysFunction · 0.85
isBitmapIndexMethod · 0.80
isSegmentBitmapIndexMethod · 0.80
ExceptionClass · 0.50
getMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
getColumnNameMethod · 0.45
getColumnsMethod · 0.45

Tested by

no test coverage detected