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

Function buildCastFunction

src/Analyzer/Utils.cpp:350–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350QueryTreeNodePtr buildCastFunction(const QueryTreeNodePtr & expression,
351 const DataTypePtr & type,
352 const ContextPtr & context,
353 bool resolve)
354{
355 std::string cast_type = type->getName();
356 auto cast_type_constant_node = std::make_shared<ConstantNode>(std::move(cast_type), std::make_shared<DataTypeString>());
357
358 std::string cast_function_name = "_CAST";
359 auto cast_function_node = std::make_shared<FunctionNode>(cast_function_name);
360 cast_function_node->getArguments().getNodes().push_back(expression);
361 cast_function_node->getArguments().getNodes().push_back(std::move(cast_type_constant_node));
362
363 if (resolve)
364 {
365 auto cast_function = FunctionFactory::instance().get(cast_function_name, context);
366 cast_function_node->resolveAsFunction(cast_function->build(cast_function_node->getArgumentColumns()));
367 }
368
369 return cast_function_node;
370}
371
372std::optional<bool> tryExtractConstantFromConditionNode(const QueryTreeNodePtr & condition_node)
373{

Calls 8

getNodesMethod · 0.80
getNameMethod · 0.45
push_backMethod · 0.45
getArgumentsMethod · 0.45
getMethod · 0.45
resolveAsFunctionMethod · 0.45
buildMethod · 0.45
getArgumentColumnsMethod · 0.45

Tested by

no test coverage detected