MCPcopy Create free account
hub / github.com/ByConity/ByConity / executeSubPipelineWithOneRow

Function executeSubPipelineWithOneRow

src/Interpreters/executeSubQuery.cpp:169–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169Block executeSubPipelineWithOneRow(
170 const ASTPtr & query, ContextMutablePtr query_context, std::function<void(InterpreterSelectQueryUseOptimizer &)> pre_execute, bool tolerate_multi_rows)
171{
172 if (!query->as<ASTSelectWithUnionQuery>())
173 throw Exception(
174 ErrorCodes::LOGICAL_ERROR,
175 "Unrecognized query type '{}' when executing subquery {}",
176 query->getID(),
177 query->formatForErrorMessage());
178
179 Block block;
180 std::exception_ptr exception;
181 auto thread = ThreadFromGlobalPool([query_context = std::move(query_context), &query, pre_execute, tolerate_multi_rows, &block, &exception]() {
182 try
183 {
184 CurrentThread::QueryScope query_scope{query_context};
185 {
186 SelectQueryOptions query_options;
187 InterpreterSelectQueryUseOptimizer interpreter{query, query_context, query_options};
188 auto block_io = interpreter.execute();
189 PullingPipelineExecutor executor(block_io.pipeline);
190
191 pre_execute(interpreter);
192
193 while (block.rows() == 0 && executor.pull(block))
194 ;
195
196 if (!tolerate_multi_rows && block.rows() != 1)
197 throw Exception(ErrorCodes::TOO_MANY_ROWS, "Unexcepted block");
198
199 Block tmp_block;
200 while (tmp_block.rows() == 0 && executor.pull(tmp_block))
201 {
202 if (tmp_block.rows() > 0)
203 throw Exception(ErrorCodes::TOO_MANY_ROWS, "Unexcepted block");
204 }
205 }
206 }
207 catch (...)
208 {
209 exception = constructException(query_context);
210 }
211 });
212 thread.join();
213
214 if (exception)
215 std::rethrow_exception(exception);
216
217 return block;
218}
219
220void executeSubPipeline(
221 const ASTPtr & query,

Callers 1

Analysis.cppFile · 0.85

Calls 9

constructExceptionFunction · 0.85
formatForErrorMessageMethod · 0.80
ExceptionClass · 0.70
getIDMethod · 0.45
executeMethod · 0.45
rowsMethod · 0.45
pullMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected