Skip to content

Commit

Permalink
Correctly close (rather than cancel) INSERT statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Robinson authored and lskuff committed Apr 29, 2013
1 parent e4b3285 commit 0d51bb1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion be/src/runtime/coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ Status Coordinator::Exec(
finalize_params_ = request->finalize_params;
}

stmt_type_ = request->stmt_type;

query_id_ = query_id;
VLOG_QUERY << "Exec() query_id=" << query_id_;
desc_tbl_ = request->desc_tbl;
Expand Down Expand Up @@ -609,7 +611,13 @@ Status Coordinator::Wait() {

// Query finalization is required only for HDFS table sinks
if (needs_finalization_) {
return FinalizeQuery();
RETURN_IF_ERROR(FinalizeQuery());
}

if (stmt_type_ == TStmtType::DML) {
// For DML queries, when Wait is done, the query is complete. Report
// Aggregate query profiles at this point.
ReportQuerySummary();
}

return Status::OK;
Expand Down
3 changes: 3 additions & 0 deletions be/src/runtime/coordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class Coordinator {
TQueryGlobals query_globals_;
TQueryOptions query_options_;

// copied from TQueryExecRequest, governs when to call ReportQuerySummary
TStmtType::type stmt_type_;

// map from id of a scan node to a specific counter in the node's profile
typedef std::map<PlanNodeId, RuntimeProfile::Counter*> CounterMap;

Expand Down
5 changes: 5 additions & 0 deletions be/src/service/impala-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ Status ImpalaServer::QueryExecState::Wait() {
RETURN_IF_ERROR(UpdateMetastore());
}

if (exec_request_.stmt_type == TStmtType::DML) {
// DML queries are finished by this point
eos_ = true;
}

return Status::OK;
}

Expand Down
4 changes: 4 additions & 0 deletions common/thrift/Frontend.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ struct TQueryExecRequest {

// The same as the output of 'explain <query>'
8: optional string query_plan

// The statement type governs when the coordinator can judge a query to be finished.
// DML queries are complete after Wait(), SELECTs may not be.
9: required Types.TStmtType stmt_type
}

enum TDdlType {
Expand Down
4 changes: 4 additions & 0 deletions fe/src/main/java/com/cloudera/impala/service/Frontend.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ public TExecRequest createExecRequest(
}
}

// Copy the statement type into the TQueryExecRequest so that it
// is visible to the coordinator.
result.query_exec_request.stmt_type = result.stmt_type;

return result;
}

Expand Down

0 comments on commit 0d51bb1

Please sign in to comment.