This is an automated email from the ASF dual-hosted git repository.
dkuzmenko 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 e489cf3a199 HIVE-27472: Iceberg: Disallow creation of temporary tables
(Denys Kuzmenko, reviewed by Attila Turoczy, Ayush Saxena, Simhadri Govindappa)
e489cf3a199 is described below
commit e489cf3a19940b843baad6999f81f7ad10f817da
Author: Denys Kuzmenko <[email protected]>
AuthorDate: Tue Jul 11 08:31:49 2023 +0300
HIVE-27472: Iceberg: Disallow creation of temporary tables (Denys Kuzmenko,
reviewed by Attila Turoczy, Ayush Saxena, Simhadri Govindappa)
Closes #4456
---
.../org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java | 5 ++++-
.../mr/hive/TestHiveIcebergStorageHandlerNoScan.java | 17 ++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
index d946531d58f..605f07728d3 100644
---
a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
+++
b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
@@ -165,6 +165,9 @@ public class HiveIcebergMetaHook implements HiveMetaHook {
@Override
public void preCreateTable(org.apache.hadoop.hive.metastore.api.Table
hmsTable) {
+ if (hmsTable.isTemporary()) {
+ throw new UnsupportedOperationException("Creation of temporary iceberg
tables is not supported.");
+ }
this.catalogProperties = getCatalogProperties(hmsTable);
// Set the table type even for non HiveCatalog based tables
@@ -173,7 +176,7 @@ public class HiveIcebergMetaHook implements HiveMetaHook {
if (!Catalogs.hiveCatalog(conf, catalogProperties)) {
if
(Boolean.parseBoolean(this.catalogProperties.getProperty(hive_metastoreConstants.TABLE_IS_CTLT)))
{
- throw new RuntimeException("CTLT target table must be a HiveCatalog
table.");
+ throw new UnsupportedOperationException("CTLT target table must be a
HiveCatalog table.");
}
// For non-HiveCatalog tables too, we should set the input and output
format
// so that the table can be read by other engines like Impala
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 aedcfdff5cc..21fb270f366 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
@@ -1693,7 +1693,22 @@ public class TestHiveIcebergStorageHandlerNoScan {
testTables.propertiesForCreateTableSQL(ImmutableMap.of())));
})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining(" CTLT target table must be a HiveCatalog
table");
+ .hasMessageContaining("CTLT target table must be a HiveCatalog table");
+ }
+
+ @Test
+ public void testCreateTemporaryTable() {
+ TableIdentifier identifier = TableIdentifier.of("default", "customers");
+ String query = String.format("CREATE temporary TABLE customers
(customer_id BIGINT, first_name STRING, last_name " +
+ "STRING) STORED BY iceberg %s %s",
+ testTables.locationForCreateTableSQL(identifier),
+ testTables.propertiesForCreateTableSQL(ImmutableMap.of()));
+
+ Assertions.assertThatThrownBy(() -> {
+ shell.executeStatement(query);
+ })
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Creation of temporary iceberg tables is not
supported");
}
@Test