From 7c40b95a04601c04527770bb42bbfdd37d9109c0 Mon Sep 17 00:00:00 2001 From: Zoltan Borok-Nagy Date: Wed, 11 May 2022 17:51:10 +0200 Subject: [PATCH] IMPALA-11287 (part 1): Disable CREATE TABLE LIKE statements for Iceberg tables We currently don't implement correct behavior for CREATE TABLE LIKE statements for Iceberg tables. Neither on the source, nor on the target table side. This patch forbids such statements until they are correctly implemented. Testing * added e2e test Change-Id: I9cee6fc82547dabf63937cc541163c1ee59a4013 Reviewed-on: http://gerrit.cloudera.org:8080/18517 Reviewed-by: Impala Public Jenkins Tested-by: Impala Public Jenkins --- .../apache/impala/analysis/CreateTableLikeStmt.java | 11 +++++++++++ .../queries/QueryTest/iceberg-negative.test | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/fe/src/main/java/org/apache/impala/analysis/CreateTableLikeStmt.java b/fe/src/main/java/org/apache/impala/analysis/CreateTableLikeStmt.java index 2dafe6c4c..29dd4c60d 100644 --- a/fe/src/main/java/org/apache/impala/analysis/CreateTableLikeStmt.java +++ b/fe/src/main/java/org/apache/impala/analysis/CreateTableLikeStmt.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.hadoop.fs.permission.FsAction; import org.apache.impala.authorization.Privilege; import org.apache.impala.catalog.FeTable; +import org.apache.impala.catalog.IcebergTable; import org.apache.impala.catalog.KuduTable; import org.apache.impala.common.AnalysisException; import org.apache.impala.common.Pair; @@ -170,6 +171,12 @@ public class CreateTableLikeStmt extends StatementBase { if (fileFormat_ == THdfsFileFormat.KUDU) { throw new AnalysisException("CREATE TABLE LIKE is not supported for Kudu tables"); } + // We currently don't support creating an Iceberg table using a CREATE TABLE LIKE + // statement (see IMPALA-11287). + if (fileFormat_ == THdfsFileFormat.ICEBERG) { + throw new AnalysisException( + "CREATE TABLE LIKE is not supported for Iceberg tables."); + } // Make sure the source table exists and the user has permission to access it. FeTable srcTable = analyzer.getTable(srcTableName_, Privilege.VIEW_METADATA); @@ -180,6 +187,10 @@ public class CreateTableLikeStmt extends StatementBase { throw new AnalysisException("Cloning a Kudu table using CREATE TABLE LIKE is " + "not supported."); } + if (IcebergTable.isIcebergTable(srcTable.getMetaStoreTable())) { + throw new AnalysisException("Cloning an Iceberg table using CREATE TABLE LIKE is " + + "not supported."); + } srcDbName_ = srcTable.getDb().getName(); analyzer.getFqTableName(tableName_).analyze(); dbName_ = analyzer.getTargetDbName(tableName_); diff --git a/testdata/workloads/functional-query/queries/QueryTest/iceberg-negative.test b/testdata/workloads/functional-query/queries/QueryTest/iceberg-negative.test index 69b0d67d8..0a3555f51 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/iceberg-negative.test +++ b/testdata/workloads/functional-query/queries/QueryTest/iceberg-negative.test @@ -602,3 +602,13 @@ select * from functional_parquet.iceberg_v2_delete_positional; ---- CATCH row_regex:.*CAUSED BY: TableLoadingException: Unsupported Iceberg V2 feature, table .* contains delete files..* ==== +---- QUERY +CREATE TABLE ice_clone LIKE functional_parquet.iceberg_non_partitioned; +---- CATCH +Cloning an Iceberg table using CREATE TABLE LIKE is not supported. +==== +---- QUERY +CREATE TABLE clone_ice LIKE functional_parquet.alltypestiny STORED AS ICEBERG; +---- CATCH +CREATE TABLE LIKE is not supported for Iceberg tables. +====