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

Function getExpressionSource

src/Analyzer/Utils.cpp:1018–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1016}
1017
1018std::pair<QueryTreeNodePtr, bool> getExpressionSource(const QueryTreeNodePtr & node)
1019{
1020 if (const auto * column = node->as<ColumnNode>())
1021 {
1022 auto source = column->getColumnSourceOrNull();
1023 if (!source)
1024 return {nullptr, false};
1025 return {source, true};
1026 }
1027
1028 if (const auto * func = node->as<FunctionNode>())
1029 {
1030 QueryTreeNodePtr source = nullptr;
1031 const auto & args = func->getArguments().getNodes();
1032 for (const auto & arg : args)
1033 {
1034 auto [arg_source, is_ok] = getExpressionSource(arg);
1035 if (!is_ok)
1036 return {nullptr, false};
1037
1038 if (!source)
1039 source = arg_source;
1040 else if (arg_source && !source->isEqual(*arg_source))
1041 return {nullptr, false};
1042 }
1043 return {source, true};
1044
1045 }
1046
1047 if (node->as<ConstantNode>())
1048 return {nullptr, true};
1049
1050 return {nullptr, false};
1051}
1052
1053/** There are no limits on the maximum size of the result for the subquery.
1054 * Since the result of the query is not the result of the entire query.

Callers 3

buildJoinGraphMethod · 0.85
resolveJoinMethod · 0.85

Calls 4

getColumnSourceOrNullMethod · 0.80
getNodesMethod · 0.80
getArgumentsMethod · 0.45
isEqualMethod · 0.45

Tested by

no test coverage detected