MCPcopy Create free account
hub / github.com/apache/impala / FinalizeHdfsDml

Method FinalizeHdfsDml

be/src/runtime/coordinator.cc:947–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947Status Coordinator::FinalizeHdfsDml() {
948 // All instances must have reported their final statuses before finalization, which is a
949 // post-condition of Wait. If the query was not successful, still try to clean up the
950 // staging directory.
951 DCHECK(has_called_wait_.Load());
952 DCHECK(finalize_params() != nullptr);
953 bool is_hive_acid = finalize_params()->__isset.write_id;
954 bool is_iceberg_table = finalize_params()->__isset.iceberg_params;
955
956 VLOG_QUERY << "Finalizing query: " << PrintId(query_id());
957 SCOPED_TIMER(finalization_timer_);
958 Status return_status = UpdateExecState(Status::OK(), nullptr, FLAGS_hostname);
959 HdfsTableDescriptor* hdfs_table = nullptr;
960 if (return_status.ok()) {
961 DCHECK(query_ctx().__isset.desc_tbl_serialized);
962 RETURN_IF_ERROR(DescriptorTbl::CreateHdfsTblDescriptor(
963 query_ctx().desc_tbl_serialized, finalize_params()->table_id, obj_pool(),
964 &hdfs_table));
965 DCHECK(hdfs_table != nullptr)
966 << "INSERT target table not known in descriptor table: "
967 << finalize_params()->table_id;
968 if (is_iceberg_table) {
969 // No-op. The data files are written by the table sink operators to their final
970 // places. We append them to the table in UpdateCatalog().
971 }
972 // There is no need for finalization for Hive ACID transactional inserts.
973 else if (!is_hive_acid) {
974 // 'write_id' is NOT set, therefore we need to do some finalization, e.g. moving
975 // files or delete old files in case of INSERT OVERWRITE.
976 return_status = dml_exec_state_.FinalizeHdfsInsert(*finalize_params(),
977 query_ctx().client_request.query_options.s3_skip_insert_staging,
978 hdfs_table, query_profile_);
979 }
980 hdfs_table->ReleaseResources();
981 } else if (is_hive_acid) {
982 parent_request_state_->AbortTransaction();
983 }
984 // Cleanup after DML operation.
985 if (is_hive_acid || is_iceberg_table) {
986 DCHECK(!finalize_params()->__isset.staging_dir);
987 } else {
988 RETURN_IF_ERROR(DeleteQueryLevelStagingDir());
989 }
990 return return_status;
991}
992
993Status Coordinator::DeleteQueryLevelStagingDir() {
994 stringstream staging_dir;

Callers

nothing calls this directly

Calls 7

PrintIdFunction · 0.85
OKFunction · 0.85
FinalizeHdfsInsertMethod · 0.80
LoadMethod · 0.45
okMethod · 0.45
ReleaseResourcesMethod · 0.45
AbortTransactionMethod · 0.45

Tested by

no test coverage detected