This is an automated email from the ASF dual-hosted git repository.
zhangbutao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new b8542439b38 HIVE-28021: Iceberg: Attempting to create a table with a
percent symbol fails(#5024)(Tim Thorpe, reviewed by Butao Zhang)
b8542439b38 is described below
commit b8542439b383d7a616155fda668152878ca67d8d
Author: tthorpeIBM <[email protected]>
AuthorDate: Fri Feb 23 10:34:53 2024 -0500
HIVE-28021: Iceberg: Attempting to create a table with a percent symbol
fails(#5024)(Tim Thorpe, reviewed by Butao Zhang)
---
.../org/apache/iceberg/hive/MetastoreLock.java | 2 +-
.../hive/TestHiveIcebergStorageHandlerNoScan.java | 25 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java
index f25a35ab783..c0d9d88ee9f 100644
---
a/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java
+++
b/iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreLock.java
@@ -126,7 +126,7 @@ public 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);
diff --git
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
index 5a63733bd1e..4995d795912 100644
---
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
+++
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
@@ -2113,4 +2113,29 @@ public class TestHiveIcebergStorageHandlerNoScan {
private String
getCurrentSnapshotForHiveCatalogTable(org.apache.iceberg.Table icebergTable) {
return ((BaseMetastoreTableOperations) ((BaseTable)
icebergTable).operations()).currentMetadataLocation();
}
+
+ @Test
+ public void testCreateTableWithPercentInName() throws IOException {
+ Assume.assumeTrue("This test is only for hive catalog", testTableType ==
TestTables.TestTableType.HIVE_CATALOG);
+
+ TableIdentifier identifier = TableIdentifier.of("default", "[|]#&%_@");
+
+ shell.executeStatement("CREATE EXTERNAL TABLE `[|]#&%_@` " +
+ "STORED BY ICEBERG " +
+ 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);
+ Assert.assertEquals(
+ HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA.asStruct(),
+ icebergTable.schema().asStruct());
+ Assert.assertEquals(PartitionSpec.unpartitioned(), icebergTable.spec());
+ }
}