amogh-jahagirdar commented on a change in pull request #4099:
URL: https://github.com/apache/iceberg/pull/4099#discussion_r805058851
##########
File path: aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java
##########
@@ -431,6 +433,34 @@ protected boolean isValidIdentifier(TableIdentifier
tableIdentifier) {
IcebergToGlueConverter.isValidTableName(tableIdentifier.name());
}
+ @Override
+ public org.apache.iceberg.Table registerTable(TableIdentifier identifier,
String metadataFileLocation) {
+ Preconditions.checkArgument(isValidIdentifier(identifier),
+ "Table identifier to register is invalid: " + identifier);
+ Preconditions.checkArgument(metadataFileLocation != null &&
!metadataFileLocation.isEmpty(),
+ "Cannot register an empty metadata file location as a table");
+ try {
+ glue.createTable(CreateTableRequest.builder()
+ .databaseName(IcebergToGlueConverter.getDatabaseName(identifier))
+ .tableInput(TableInput.builder()
+ .name(IcebergToGlueConverter.getTableName(identifier))
+ .tableType(GlueTableOperations.GLUE_EXTERNAL_TABLE_TYPE)
+ .parameters(ImmutableMap.of(
+ BaseMetastoreTableOperations.TABLE_TYPE_PROP,
+
BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.toLowerCase(Locale.ENGLISH),
+ BaseMetastoreTableOperations.METADATA_LOCATION_PROP,
+ metadataFileLocation))
+ .build())
+ .build());
+ } catch (software.amazon.awssdk.services.glue.model.AlreadyExistsException
e) {
Review comment:
Do we need the full class path here? Is there another
AlreadyExistsException?
##########
File path: aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java
##########
@@ -431,6 +433,34 @@ protected boolean isValidIdentifier(TableIdentifier
tableIdentifier) {
IcebergToGlueConverter.isValidTableName(tableIdentifier.name());
}
+ @Override
+ public org.apache.iceberg.Table registerTable(TableIdentifier identifier,
String metadataFileLocation) {
+ Preconditions.checkArgument(isValidIdentifier(identifier),
+ "Table identifier to register is invalid: " + identifier);
+ Preconditions.checkArgument(metadataFileLocation != null &&
!metadataFileLocation.isEmpty(),
+ "Cannot register an empty metadata file location as a table");
+ try {
+ glue.createTable(CreateTableRequest.builder()
+ .databaseName(IcebergToGlueConverter.getDatabaseName(identifier))
+ .tableInput(TableInput.builder()
+ .name(IcebergToGlueConverter.getTableName(identifier))
+ .tableType(GlueTableOperations.GLUE_EXTERNAL_TABLE_TYPE)
+ .parameters(ImmutableMap.of(
+ BaseMetastoreTableOperations.TABLE_TYPE_PROP,
+
BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.toLowerCase(Locale.ENGLISH),
+ BaseMetastoreTableOperations.METADATA_LOCATION_PROP,
+ metadataFileLocation))
+ .build())
Review comment:
Nit: I think it may be more readable to build the table input separately
and then pass it in here.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]