github-actions[bot] opened a new pull request, #9669:
URL: https://github.com/apache/gravitino/pull/9669

   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): support xxx"
        - "[#233] fix: check null before access result in xxx"
        - "[MINOR] refactor: fix typo in variable name"
        - "[MINOR] docs: fix typo in README"
        - "[#255] test: fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   
   This PR fixes the Iceberg system.migrate() procedure for JDBC-backed 
catalogs by preserving stageCreate flag in IcebergTableOperationExecutor
   
   ### Why are the changes needed?
   
   The system.migrate() procedure fails when migrating external Iceberg tables 
to JDBC-backed catalogs (MySQL, PostgreSQL) with the error:
   ```
   org.apache.iceberg.exceptions.AlreadyExistsException: Table already exists 
in database
   ```
   
   Root Cause:
   The staging protocol requires 3 distinct phases to safely migrate tables 
with existing data:
   
   Stage: Create table metadata without registering in the catalog
   Write: Client writes/copies data files to the staged location
   Commit: Atomically register the table with assert-create to prevent race 
conditions
   JDBC catalogs skip phase 1 and immediately commit the table to the database, 
causing the migration to fail because the table already exists when phase 3 
attempts the final commit.
   
   This is a critical bug that makes it impossible to migrate existing Iceberg 
tables to Gravitino JDBC catalogs.
   
   Fix: #9666 
   
   ### Does this PR introduce _any_ user-facing change?
   
   No user-facing API changes. This fix enables the system.migrate() procedure 
to work correctly with JDBC catalogs, which was previously broken.
   
   ### How was this patch tested?
   - Added unit test
   
   Manual Testing:
   
   Configured Gravitino with JDBC catalog (MySQL backend)
   Created external Iceberg table in Hive catalog
   Successfully migrated table using CALL 
system.migrate('catalog.database.table')
   Verified table metadata and data files are correctly staged and committed
   Confirmed migration fails without the fix (table already exists error)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to