Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Exception Handling in AWS Glue renameTable Method #11165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jishangarg
Copy link

@jishangarg jishangarg commented Sep 18, 2024

Related to issue: #11155

This PR addresses an issue in the AWS Glue renameTable method where an incorrect exception is thrown when a table with the new name already exists. According to the Iceberg Catalog interface, the method should throw org.apache.iceberg.exceptions.AlreadyExistsException. However, it currently throws software.amazon.awssdk.services.glue.model.AlreadyExistsException, leading to inconsistent behavior.

Problem:
The renameTable method throws an AWS Glue-specific AlreadyExistsException instead of the expected Iceberg-specific AlreadyExistsException. This violates the contract defined by the Iceberg Catalog interface and can cause confusion for applications relying on the Iceberg exception handling.

Solution:
Updated the glue.createTable() call: The AlreadyExistsException from AWS Glue is now caught and rethrown as Iceberg’s org.apache.iceberg.exceptions.AlreadyExistsException. Ensures that the Iceberg exception is consistently used in line with the catalog interface specification.

Changes:
Wrapped the glue.createTable() call in a try-catch block. Caught software.amazon.awssdk.services.glue.model.AlreadyExistsException and rethrew it as org.apache.iceberg.exceptions.AlreadyExistsException with an appropriate error message. Retained the existing rollback logic for handling failures when dropping the old table.

Impact:
Ensures consistent exception handling in the renameTable method. Aligns the behavior with the Iceberg API contract. No impact on backward compatibility, as this only corrects exception handling. This PR ensures that the renameTable operation behaves as expected according to the Iceberg documentation and resolves the mismatch in exception handling.

This PR addresses an issue in the AWS Glue renameTable method where an incorrect exception is thrown when a table with the new name already exists. According to the Iceberg Catalog interface, the method should throw org.apache.iceberg.exceptions.AlreadyExistsException. However, it currently throws software.amazon.awssdk.services.glue.model.AlreadyExistsException, leading to inconsistent behavior.

Problem:
The renameTable method throws an AWS Glue-specific AlreadyExistsException instead of the expected Iceberg-specific AlreadyExistsException.
This violates the contract defined by the Iceberg Catalog interface and can cause confusion for applications relying on the Iceberg exception handling.

Solution:
Updated the glue.createTable() call: The AlreadyExistsException from AWS Glue is now caught and rethrown as Iceberg’s org.apache.iceberg.exceptions.AlreadyExistsException.
Ensures that the Iceberg exception is consistently used in line with the catalog interface specification.

Changes:
Wrapped the glue.createTable() call in a try-catch block.
Caught software.amazon.awssdk.services.glue.model.AlreadyExistsException and rethrew it as org.apache.iceberg.exceptions.AlreadyExistsException with an appropriate error message.
Retained the existing rollback logic for handling failures when dropping the old table.

Impact:
Ensures consistent exception handling in the renameTable method.
Aligns the behavior with the Iceberg API contract.
No impact on backward compatibility, as this only corrects exception handling.
This PR ensures that the renameTable operation behaves as expected according to the Iceberg documentation and resolves the mismatch in exception handling.
@jishangarg
Copy link
Author

Can somebody please review my PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant