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

Method processQuery

src/Server/StatelessWorker/StatelessWorkerEndpoint.cpp:199–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void StatelessWorkerEndpoint::processQuery(const HTMLForm & params, ReadBufferPtr body, WriteBuffer & out, HTTPServerResponse & response)
200{
201 auto operation = params.get("operation");
202 auto task_id = params.get("task_id");
203
204 if (operation == "start")
205 {
206 auto unique_temp_file_path = params.get("temp_path");
207 /// Deserialize task fields from the request body
208 DistributedQueryTaskDescription task_description;
209 deserializeTask(task_description, *body);
210 body->eof();
211 body.reset();
212
213 /// Pass it to the runner to start execution
214 task_runner->startTask(task_id, task_description, unique_temp_file_path);
215 }
216 else if (operation == "get_status")
217 {
218 UInt64 wait_milliseconds = 0;
219 if (params.has("wait_for_ms"))
220 wait_milliseconds = parse<UInt64>(params.get("wait_for_ms"));
221
222 UInt64 client_version = DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS;
223 if (params.has("client_version"))
224 client_version = parse<UInt64>(params.get("client_version"));
225
226 body->eof();
227 body.reset();
228
229 auto status = task_runner->getStatus(task_id, wait_milliseconds);
230 DistributedQueryTaskStatus task_status;
231 task_status.progress = std::move(status.progress);
232
233 switch (status.result)
234 {
235 case StatelessTaskExecutor::TaskRunnig:
236 {
237 response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
238 task_status.status = "Running";
239 break;
240 }
241 case StatelessTaskExecutor::TaskFinished:
242 {
243 response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
244 task_status.status = "Finished";
245 break;
246 }
247 case StatelessTaskExecutor::TaskCancelled:
248 {
249 response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
250 task_status.status = "Cancelled";
251 break;
252 }
253 case StatelessTaskExecutor::TaskFailed:
254 {
255 response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
256 task_status.status = "Failed";

Callers

nothing calls this directly

Calls 13

deserializeTaskFunction · 0.85
forgetTaskMethod · 0.80
formatFunction · 0.50
writeStringFunction · 0.50
getMethod · 0.45
eofMethod · 0.45
resetMethod · 0.45
startTaskMethod · 0.45
hasMethod · 0.45
getStatusMethod · 0.45
setStatusMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected