| 1071 | } |
| 1072 | |
| 1073 | QueryTreeNodePtr buildQueryToReadColumnsFromTableExpression(const NamesAndTypes & columns, |
| 1074 | const QueryTreeNodePtr & table_expression, |
| 1075 | ContextMutablePtr & context) |
| 1076 | { |
| 1077 | auto projection_columns = columns; |
| 1078 | |
| 1079 | QueryTreeNodes subquery_projection_nodes; |
| 1080 | subquery_projection_nodes.reserve(projection_columns.size()); |
| 1081 | |
| 1082 | for (const auto & column : projection_columns) |
| 1083 | subquery_projection_nodes.push_back(std::make_shared<ColumnNode>(column, table_expression)); |
| 1084 | |
| 1085 | if (subquery_projection_nodes.empty()) |
| 1086 | { |
| 1087 | auto constant_data_type = std::make_shared<DataTypeUInt64>(); |
| 1088 | subquery_projection_nodes.push_back(std::make_shared<ConstantNode>(1UL, constant_data_type)); |
| 1089 | projection_columns.push_back({"1", std::move(constant_data_type)}); |
| 1090 | } |
| 1091 | |
| 1092 | updateContextForSubqueryExecution(context); |
| 1093 | |
| 1094 | auto query_node = std::make_shared<QueryNode>(std::move(context)); |
| 1095 | |
| 1096 | query_node->getProjection().getNodes() = std::move(subquery_projection_nodes); |
| 1097 | query_node->resolveProjectionColumns(projection_columns); |
| 1098 | query_node->getJoinTree() = table_expression; |
| 1099 | |
| 1100 | return query_node; |
| 1101 | } |
| 1102 | |
| 1103 | QueryTreeNodePtr buildSubqueryToReadColumnsFromTableExpression(const NamesAndTypes & columns, |
| 1104 | const QueryTreeNodePtr & table_expression, |
no test coverage detected