| 2556 | } |
| 2557 | |
| 2558 | void ClientRequestState::ExecMigrateRequestImpl() { |
| 2559 | // A convert table request holds the query strings for the sub-queries. These are |
| 2560 | // populated by ConvertTableToIcebergStmt in the Frontend during analysis. |
| 2561 | const TConvertTableRequest& params = exec_request().convert_table_request; |
| 2562 | { |
| 2563 | RuntimeProfile* child_profile = |
| 2564 | RuntimeProfile::Create(&profile_pool_, "Child Queries 1"); |
| 2565 | profile_->AddChild(child_profile); |
| 2566 | vector<ChildQuery> child_queries; |
| 2567 | |
| 2568 | // Prepare: SET some table properties for the original table. |
| 2569 | RuntimeProfile* set_hdfs_table_profile = RuntimeProfile::Create( |
| 2570 | &profile_pool_, "Set properties for HDFS table query"); |
| 2571 | child_profile->AddChild(set_hdfs_table_profile); |
| 2572 | child_queries.emplace_back(params.set_hdfs_table_properties_query, this, |
| 2573 | parent_server_, set_hdfs_table_profile, &profile_pool_); |
| 2574 | |
| 2575 | // Prepare: RENAME the HDFS table to a temporary HDFS table. |
| 2576 | RuntimeProfile* rename_hdfs_table_profile = RuntimeProfile::Create( |
| 2577 | &profile_pool_, "Rename HDFS table query"); |
| 2578 | child_profile->AddChild(rename_hdfs_table_profile); |
| 2579 | child_queries.emplace_back(params.rename_hdfs_table_to_temporary_query, |
| 2580 | this, parent_server_, rename_hdfs_table_profile, &profile_pool_); |
| 2581 | |
| 2582 | // Prepare: REFRESH the temporary HDFS table. |
| 2583 | RuntimeProfile* refresh_hdfs_table_profile = RuntimeProfile::Create( |
| 2584 | &profile_pool_, "Refresh temporary HDFS table query"); |
| 2585 | child_profile->AddChild(refresh_hdfs_table_profile); |
| 2586 | child_queries.emplace_back(params.refresh_temporary_hdfs_table_query, this, |
| 2587 | parent_server_, refresh_hdfs_table_profile, &profile_pool_); |
| 2588 | |
| 2589 | // Execute child queries |
| 2590 | unique_ptr<ChildQueryExecutor> query_executor(new ChildQueryExecutor()); |
| 2591 | RETURN_VOID_IF_ERROR(query_executor->ExecAsync(move(child_queries))); |
| 2592 | vector<ChildQuery*> completed_queries; |
| 2593 | Status query_status = query_executor->WaitForAll(&completed_queries); |
| 2594 | if (!query_status.ok()) AddTableResetHints(params, &query_status); |
| 2595 | { |
| 2596 | lock_guard<mutex> l(lock_); |
| 2597 | RETURN_VOID_IF_ERROR(UpdateQueryStatus(query_status)); |
| 2598 | } |
| 2599 | } |
| 2600 | // Create an external Iceberg table using the data of the HDFS table. |
| 2601 | Status status = frontend_->Convert(exec_request()); |
| 2602 | if (!status.ok()) AddTableResetHints(params, &status); |
| 2603 | { |
| 2604 | lock_guard<mutex> l(lock_); |
| 2605 | RETURN_VOID_IF_ERROR(UpdateQueryStatus(status)); |
| 2606 | } |
| 2607 | { |
| 2608 | RuntimeProfile* child_profile = |
| 2609 | RuntimeProfile::Create(&profile_pool_, "Child Queries 2"); |
| 2610 | profile_->AddChild(child_profile); |
| 2611 | vector<ChildQuery> child_queries; |
| 2612 | |
| 2613 | if (params.__isset.create_iceberg_table_query) { |
| 2614 | // Prepare: CREATE the Iceberg table that inherits HDFS table location. |
| 2615 | RuntimeProfile* create_iceberg_table_profile = RuntimeProfile::Create( |