| 121 | |
| 122 | |
| 123 | void InterpreterParallelWithQuery::executeSubquery(ASTPtr subquery, ContextMutablePtr subquery_context) |
| 124 | { |
| 125 | auto query_io = executeQuery(subquery->formatWithSecretsOneLine(), subquery_context, QueryFlags{ .internal = true }).second; |
| 126 | |
| 127 | auto & pipeline = query_io.pipeline; |
| 128 | |
| 129 | if (!pipeline.initialized()) |
| 130 | { |
| 131 | /// The subquery interpreter (called by executeQuery()) has already done all the work. |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | if (!pipeline.completed()) |
| 136 | { |
| 137 | /// We allow only queries without input and output to be combined using PARALLEL WITH clause. |
| 138 | String reason; |
| 139 | if (pipeline.pushing() && pipeline.pulling()) |
| 140 | reason = "has both input and output"; |
| 141 | else if (pipeline.pushing()) |
| 142 | reason = "has input"; |
| 143 | else if (pipeline.pulling()) |
| 144 | reason = "has output"; |
| 145 | chassert(!reason.empty()); |
| 146 | |
| 147 | if (subquery->getQueryKind() == IAST::QueryKind::Select) |
| 148 | reason += " (Use UNION to combine select queries)"; |
| 149 | |
| 150 | throw Exception(ErrorCodes::INCORRECT_QUERY, |
| 151 | "Query {} can't be combined with other queries using PARALLEL WITH clause because this query {}", |
| 152 | subquery->formatForLogging(), reason); |
| 153 | } |
| 154 | |
| 155 | chassert(pipeline.completed()); |
| 156 | std::lock_guard lock{mutex}; |
| 157 | combined_pipeline.addCompletedPipeline(pipeline); |
| 158 | |
| 159 | io_holders.push_back(std::move(query_io)); |
| 160 | |
| 161 | /// TODO: Special processing for ON CLUSTER queries and also for queries related to a replicated database is required. |
| 162 | } |
| 163 | |
| 164 | |
| 165 | void InterpreterParallelWithQuery::executeCombinedPipeline() |
nothing calls this directly
no test coverage detected