aakashofficial-k01 opened a new pull request, #4362:
URL: https://github.com/apache/amoro/pull/4362

   ## Why are the changes needed?
   
   When duplicate table creation is requested, `RestCatalogService`'s internal 
table manager throws `org.apache.amoro.exception.AlreadyExistsException`. 
Because `IcebergRestErrorCode.exceptionToCode()` only checked for 
`org.apache.iceberg.exceptions.AlreadyExistsException`, the check evaluated to 
false and returned HTTP 500 (`InternalServerError`), violating the Iceberg REST 
OpenAPI specification (which requires 409 Conflict) and breaking client 
idempotency for compute engines like Spark, PyIceberg, and Trino.
   
   Additionally, `createTable()` and `commitCreateTable()` did not check table 
existence upfront, writing physical metadata files to object storage before 
detecting collision and triggering rollback deletions.
   
   Close #4361.
   
   ## Brief change log
   
   - Added upfront `checkAlreadyExists(!catalog.tableExists(database, 
tableName), "Table", tableName)` to `createTable()` and `commitCreateTable()`.
   - Mapped `org.apache.amoro.exception.AlreadyExistsException` and 
`BlockerConflictException` to `Conflict` (HTTP 409) in 
`IcebergRestErrorCode.exceptionToCode()`.
   - Mapped `org.apache.amoro.exception.ForbiddenException` to `Forbidden` 
(HTTP 403).
   - Added unit test assertions in `TestRestCatalogService.java`.
   - Added integration test coverage in 
`TestInternalIcebergCatalogService.java` (`testCreateTableAlreadyExists` and 
`testCommitCreateTableAlreadyExists`).
   
   ## How was this patch tested?
   
   - [x] Added positive and negative test coverage.
     `./mvnw test -pl amoro-ams -am -Dtest=TestRestCatalogService`: BUILD 
SUCCESS
   - [x] Ran style and checkstyle validation:
     `./mvnw checkstyle:check spotless:check -pl amoro-ams`: BUILD SUCCESS (0 
violations)
   - [x] Verified live on local Docker playground:
     - `POST /v1/catalogs/lakehouse/namespaces/test_db/tables` returned HTTP 
409 Conflict on duplicate table creation. Upfront existence check skipped 
redundant storage writes.
     - `POST /v1/catalogs/lakehouse/namespaces/test_db/tables/test_table` 
returned HTTP 409 Conflict on duplicate staged commit.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no


-- 
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