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

HIVE-28021: escape percent symbol #9667

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Expand Up @@ -130,7 +130,7 @@ class MetastoreLock implements HiveLock {
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("iceberg-hive-lock-heartbeat-" + fullName + "-%d")
.setNameFormat("iceberg-hive-lock-heartbeat-" + fullName.replace("%", "%%") + "-%d")
.build());

initTableLevelLockCache(tableLevelLockCacheEvictionTimeout);
Expand Down
Expand Up @@ -966,4 +966,41 @@ private String getCurrentSnapshotForHiveCatalogTable(org.apache.iceberg.Table ic
return ((BaseMetastoreTableOperations) ((BaseTable) icebergTable).operations())
.currentMetadataLocation();
}

@Test
public void testCreateTableWithPercentInName() throws IOException {
Assume.assumeTrue("This test requires Hive Version 4.", HiveVersion.min(HiveVersion.HIVE_4));
tthorpeIBM marked this conversation as resolved.
Show resolved Hide resolved

TableIdentifier identifier = TableIdentifier.of("default", "[|]#&%_@");

shell.executeStatement(
"CREATE EXTERNAL TABLE `[|]#&%_@` "
+ "STORED BY 'org.apache.iceberg.mr.hive.HiveIcebergStorageHandler' "
+ testTables.locationForCreateTableSQL(identifier)
+ "TBLPROPERTIES ('"
+ InputFormatConfig.TABLE_SCHEMA
+ "'='"
+ SchemaParser.toJson(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA)
+ "', '"
+ InputFormatConfig.PARTITION_SPEC
+ "'='"
+ PartitionSpecParser.toJson(PartitionSpec.unpartitioned())
+ "', 'dummy'='test', '"
+ InputFormatConfig.EXTERNAL_TABLE_PURGE
+ "'='TRUE', '"
+ InputFormatConfig.CATALOG_NAME
+ "'='"
+ testTables.catalogName()
+ "')");

// Check the Iceberg table data
org.apache.iceberg.Table icebergTable = testTables.loadTable(identifier);
Assume.assumeTrue(
"This test is only for hive catalog",
testTableType == TestTables.TestTableType.HIVE_CATALOG);
Assert.assertEquals(
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA.asStruct(),
icebergTable.schema().asStruct());
Assert.assertEquals(PartitionSpec.unpartitioned(), icebergTable.spec());
}
}