| 1016 | } |
| 1017 | |
| 1018 | std::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. |
no test coverage detected