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

Method executeSubquery

src/Interpreters/InterpreterParallelWithQuery.cpp:123–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121
122
123void 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
165void InterpreterParallelWithQuery::executeCombinedPipeline()

Callers

nothing calls this directly

Calls 12

completedMethod · 0.80
pushingMethod · 0.80
pullingMethod · 0.80
formatForLoggingMethod · 0.80
addCompletedPipelineMethod · 0.80
executeQueryFunction · 0.70
ExceptionClass · 0.70
initializedMethod · 0.45
emptyMethod · 0.45
getQueryKindMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected