diff --git a/aws/src/integration/java/org/apache/iceberg/aws/glue/GlueTestBase.java b/aws/src/integration/java/org/apache/iceberg/aws/glue/GlueTestBase.java index c47673ab7fa2..3d5e6da2c605 100644 --- a/aws/src/integration/java/org/apache/iceberg/aws/glue/GlueTestBase.java +++ b/aws/src/integration/java/org/apache/iceberg/aws/glue/GlueTestBase.java @@ -63,10 +63,10 @@ public class GlueTestBase { // iceberg static GlueCatalog glueCatalog; static GlueCatalog glueCatalogWithSkip; + static GlueCatalog glueCatalogWithSkipNameValidation; static Schema schema = new Schema(Types.NestedField.required(1, "c1", Types.StringType.get(), "c1")); static PartitionSpec partitionSpec = PartitionSpec.builderFor(schema).build(); - // table location properties static final Map tableLocationProperties = ImmutableMap.of( TableProperties.WRITE_DATA_LOCATION, "s3://" + testBucketName + "/writeDataLoc", @@ -85,6 +85,11 @@ public static void beforeClass() { glueCatalogWithSkip = new GlueCatalog(); glueCatalogWithSkip.initialize(catalogName, testBucketPath, properties, glue, LockManagers.defaultLockManager(), fileIO); + glueCatalogWithSkipNameValidation = new GlueCatalog(); + AwsProperties propertiesSkipNameValidation = new AwsProperties(); + propertiesSkipNameValidation.setGlueCatalogSkipNameValidation(true); + glueCatalogWithSkipNameValidation.initialize(catalogName, testBucketPath, propertiesSkipNameValidation, glue, + LockManagers.defaultLockManager(), fileIO); } @AfterClass diff --git a/aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java b/aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java index f493ccd73d77..92b906a44944 100644 --- a/aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java +++ b/aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java @@ -298,6 +298,20 @@ public void testCommitTableSkipArchive() { .databaseName(namespace).tableName(tableName).build()).tableVersions().size()); } + @Test + public void testCommitTableSkipNameValidation() { + String namespace = "dd-dd"; + namespaces.add(namespace); + glueCatalogWithSkipNameValidation.createNamespace(Namespace.of(namespace)); + String tableName = "cc-cc"; + glueCatalogWithSkipNameValidation.createTable( + TableIdentifier.of(namespace, tableName), schema, partitionSpec, tableLocationProperties); + GetTableResponse response = glue.getTable(GetTableRequest.builder() + .databaseName(namespace).name(tableName).build()); + Assert.assertEquals(namespace, response.table().databaseName()); + Assert.assertEquals(tableName, response.table().name()); + } + @Test public void testColumnCommentsAndParameters() { String namespace = createNamespace(); diff --git a/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java b/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java index 88c94c12d2b5..755005abe6e1 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java +++ b/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java @@ -497,6 +497,10 @@ public boolean removeProperties(Namespace namespace, Set properties) thr @Override protected boolean isValidIdentifier(TableIdentifier tableIdentifier) { + if (awsProperties.glueCatalogSkipNameValidation()) { + return true; + } + return IcebergToGlueConverter.isValidNamespace(tableIdentifier.namespace()) && IcebergToGlueConverter.isValidTableName(tableIdentifier.name()); } diff --git a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java index b81d1cf0cb65..b24fc7e0ccd1 100644 --- a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java +++ b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java @@ -479,4 +479,13 @@ public void testTablePropsDefinedAtCatalogLevel() { Assert.assertTrue(properties.containsKey("table-override.key4")); Assert.assertEquals("catalog-override-key4", properties.get("table-override.key4")); } + + @Test + public void testValidateIdentifierSkipNameValidation() { + AwsProperties props = new AwsProperties(); + props.setGlueCatalogSkipNameValidation(true); + glueCatalog.initialize(CATALOG_NAME, WAREHOUSE_PATH, props, glue, + LockManagers.defaultLockManager(), null); + Assert.assertEquals(glueCatalog.isValidIdentifier(TableIdentifier.parse("db-1.a-1")), true); + } }