You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "bharos (via GitHub)" <gi...@apache.org> on 2026/01/09 20:19:34 UTC
[I] [Bug report] Iceberg migrate procedure fails with "table already exists" for JDBC catalogs [gravitino]
bharos opened a new issue, #9666:
URL: https://github.com/apache/gravitino/issues/9666
### Version
main branch
### Describe what's wrong
The Iceberg `system.migrate()` procedure fails when attempting to migrate external tables to JDBC-backed catalogs (MySQL, PostgreSQL) with error "table already exists in database".
### Error message and/or stacktrace
org.apache.iceberg.exceptions.AlreadyExistsException: Table already exists in database: test_database.migrate_test_123
at org.apache.iceberg.jdbc.JdbcCatalog.createTable(JdbcCatalog.java:...)
at org.apache.iceberg.rest.CatalogHandlers.stageTableCreate(CatalogHandlers.java:...)
### How to reproduce
1. Configure Gravitino with JDBC catalog (MySQL or PostgreSQL backend)
2. Create external Iceberg table in Hive or another catalog
3. Attempt to migrate using: `CALL system.migrate('source_catalog.db.table')`
4. Observe "table already exists" error
Expected: Migration should succeed using 3-phase staging protocol
Actual: Fails because JDBC catalog commits table prematurely
### Additional context
_No response_
--
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: commits-unsubscribe@gravitino.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug report] Iceberg migrate procedure fails with "table already exists" for JDBC catalogs [gravitino]
Posted by "bharos (via GitHub)" <gi...@apache.org>.
bharos commented on issue #9666:
URL: https://github.com/apache/gravitino/issues/9666#issuecomment-3730452669
## Proposed Fix
Planning to issue a PR with:
### Fix 1: Preserve `stageCreate` flag in IcebergTableOperationExecutor
**File:** `core/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/ops/IcebergTableOperationExecutor.java`
When the executor rebuilds a `CreateTableRequest` to override the owner, it should now preserves the `stageCreate=true` flag:
```java
if (createTableRequest.stageCreate()) {
builder.stageCreate(); // Preserve staging flag
}
```
Fix 2: Custom staging implementation for JDBC catalogs
File: IcebergCatalogWrapper.java
Add stageTableCreateWithoutCommit() method that bypasses Iceberg's CatalogHandlers.stageTableCreate() (which incorrectly calls createTransaction() for JDBC catalogs). This custom implementation:
Computes table location without accessing the catalog (which would trigger a commit)
Builds TableMetadata with proper defaults (Iceberg automatically adds timestamps)
Returns staged metadata without catalog registration, allowing the 3-phase migration protocol to work correctly
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug report] Iceberg migrate procedure fails with "table already exists" for JDBC catalogs [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi closed issue #9666: [Bug report] Iceberg migrate procedure fails with "table already exists" for JDBC catalogs
URL: https://github.com/apache/gravitino/issues/9666
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org