MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / tryExtractConstantFromConditionNode

Function tryExtractConstantFromConditionNode

src/Analyzer/Utils.cpp:372–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372std::optional<bool> tryExtractConstantFromConditionNode(const QueryTreeNodePtr & condition_node)
373{
374 const auto * constant_node = condition_node ? condition_node->as<ConstantNode>() : nullptr;
375 if (!constant_node)
376 return {};
377
378 const auto & value = constant_node->getValue();
379 auto constant_type = constant_node->getResultType();
380 constant_type = removeNullable(removeLowCardinality(constant_type));
381
382 auto which_constant_type = WhichDataType(constant_type);
383 if (!which_constant_type.isUInt8() && !which_constant_type.isNothing())
384 return {};
385
386 if (value.isNull())
387 return false;
388
389 auto predicate_value = static_cast<UInt8>(value.safeGet<UInt8>());
390 return predicate_value > 0;
391}
392
393static ASTPtr convertIntoTableExpressionAST(
394 const QueryTreeNodePtr & table_expression_node,

Callers 4

buildPlanForQueryNodeMethod · 0.85
buildJoinStepLogicalFunction · 0.85
resolveFunctionMethod · 0.85

Calls 8

removeLowCardinalityFunction · 0.85
WhichDataTypeClass · 0.85
isUInt8Method · 0.80
isNothingMethod · 0.80
removeNullableFunction · 0.50
getValueMethod · 0.45
getResultTypeMethod · 0.45
isNullMethod · 0.45

Tested by

no test coverage detected