| 1361 | } |
| 1362 | |
| 1363 | Status ImpalaServer::ExecuteInternal(const TQueryCtx& query_ctx, |
| 1364 | const TExecRequest* external_exec_request, |
| 1365 | const shared_ptr<SessionState>& session_state, bool* registered_query, |
| 1366 | QueryHandle* query_handle) { |
| 1367 | DCHECK(session_state != nullptr); |
| 1368 | DCHECK(query_handle != nullptr); |
| 1369 | DCHECK(registered_query != nullptr); |
| 1370 | *registered_query = false; |
| 1371 | // Create the QueryDriver for this query. CreateNewDriver creates the associated |
| 1372 | // ClientRequestState as well. |
| 1373 | QueryDriver::CreateNewDriver(this, query_handle, query_ctx, session_state); |
| 1374 | |
| 1375 | if ((*query_handle)->otel_trace_query()) { |
| 1376 | (*query_handle)->otel_trace_manager()->EndChildSpanInit(); |
| 1377 | (*query_handle)->otel_trace_manager()->StartChildSpanSubmitted(); |
| 1378 | } |
| 1379 | |
| 1380 | bool is_external_req = external_exec_request != nullptr; |
| 1381 | |
| 1382 | if (is_external_req && external_exec_request->remote_submit_time) { |
| 1383 | (*query_handle)->SetRemoteSubmitTime(external_exec_request->remote_submit_time); |
| 1384 | } |
| 1385 | |
| 1386 | (*query_handle)->query_events()->MarkEvent("Query submitted"); |
| 1387 | |
| 1388 | if ((*query_handle)->otel_trace_query()) { |
| 1389 | (*query_handle)->otel_trace_manager()->EndChildSpanSubmitted(); |
| 1390 | (*query_handle)->otel_trace_manager()->StartChildSpanPlanning(); |
| 1391 | } |
| 1392 | |
| 1393 | { |
| 1394 | // Keep a lock on query_handle so that registration and setting |
| 1395 | // result_metadata are atomic. |
| 1396 | lock_guard<mutex> l(*(*query_handle)->lock()); |
| 1397 | |
| 1398 | // register exec state as early as possible so that queries that |
| 1399 | // take a long time to plan show up, and to handle incoming status |
| 1400 | // reports before execution starts. |
| 1401 | RETURN_IF_ERROR(RegisterQuery(query_ctx.query_id, session_state, query_handle)); |
| 1402 | *registered_query = true; |
| 1403 | |
| 1404 | DebugActionNoFail((*query_handle)->query_options(), "EXECUTE_INTERNAL_REGISTERED"); |
| 1405 | |
| 1406 | size_t statement_length = query_ctx.client_request.stmt.length(); |
| 1407 | int32_t max_statement_length = |
| 1408 | query_ctx.client_request.query_options.max_statement_length_bytes; |
| 1409 | if (max_statement_length > 0 && statement_length > max_statement_length) { |
| 1410 | return Status(ErrorMsg(TErrorCode::MAX_STATEMENT_LENGTH_EXCEEDED, |
| 1411 | statement_length, max_statement_length)); |
| 1412 | } |
| 1413 | |
| 1414 | if (is_external_req) { |
| 1415 | // Use passed in exec_request |
| 1416 | RETURN_IF_ERROR(query_handle->query_driver()->SetExternalPlan( |
| 1417 | query_ctx, *external_exec_request)); |
| 1418 | |
| 1419 | if(external_exec_request->query_exec_request.query_ctx.transaction_id > 0) { |
| 1420 | RETURN_IF_ERROR(exec_env_->frontend()->addTransaction( |
nothing calls this directly
no test coverage detected