Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> tableLocationProperties = ImmutableMap.of(
TableProperties.WRITE_DATA_LOCATION, "s3://" + testBucketName + "/writeDataLoc",
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ public boolean removeProperties(Namespace namespace, Set<String> properties) thr

@Override
protected boolean isValidIdentifier(TableIdentifier tableIdentifier) {
if (awsProperties.glueCatalogSkipNameValidation()) {
return true;
}

return IcebergToGlueConverter.isValidNamespace(tableIdentifier.namespace()) &&
IcebergToGlueConverter.isValidTableName(tableIdentifier.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}