diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties index 561d1f2812..32291223c5 100644 --- a/itests/src/test/resources/testconfiguration.properties +++ b/itests/src/test/resources/testconfiguration.properties @@ -965,7 +965,9 @@ minillaplocal.query.files=\ stats_date.q,\ dst.q,\ q93_with_constraints.q,\ - approx_distinct.q + approx_distinct.q,\ + ctas_empty_source.q + encrypted.query.files=encryption_join_unencrypted_tbl.q,\ encryption_insert_partition_static.q,\ diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java index c623adfb4d..52e8dcb090 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java @@ -98,6 +98,7 @@ import org.apache.hadoop.hive.ql.io.NullRowsInputFormat; import org.apache.hadoop.hive.ql.io.OneNullRowInputFormat; import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat; +import org.apache.hadoop.hive.ql.io.ZeroRowsInputFormat; import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatchCtx; import org.apache.hadoop.hive.ql.lib.Dispatcher; import org.apache.hadoop.hive.ql.lib.Node; @@ -347,6 +348,7 @@ // For metadataonly or empty rows optimizations, null/onerow input format can be selected. supportedAcidInputFormats.add(NullRowsInputFormat.class.getName()); supportedAcidInputFormats.add(OneNullRowInputFormat.class.getName()); + supportedAcidInputFormats.add(ZeroRowsInputFormat.class.getName()); } private boolean isTestVectorizationSuppressExplainExecutionMode; diff --git a/ql/src/test/queries/clientpositive/ctas_empty_source.q b/ql/src/test/queries/clientpositive/ctas_empty_source.q new file mode 100644 index 0000000000..e587947bdd --- /dev/null +++ b/ql/src/test/queries/clientpositive/ctas_empty_source.q @@ -0,0 +1,5 @@ + +drop table if exists testctas1; +drop table if exists testctas2; +create table testctas1 (id int); +create table testctas2 as select * from testctas1 where 1=2; diff --git a/ql/src/test/results/clientpositive/llap/ctas_empty_source.q.out b/ql/src/test/results/clientpositive/llap/ctas_empty_source.q.out new file mode 100644 index 0000000000..0285f1d6c6 --- /dev/null +++ b/ql/src/test/results/clientpositive/llap/ctas_empty_source.q.out @@ -0,0 +1,27 @@ +PREHOOK: query: drop table if exists testctas1 +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table if exists testctas1 +POSTHOOK: type: DROPTABLE +PREHOOK: query: drop table if exists testctas2 +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table if exists testctas2 +POSTHOOK: type: DROPTABLE +PREHOOK: query: create table testctas1 (id int) +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@testctas1 +POSTHOOK: query: create table testctas1 (id int) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@testctas1 +PREHOOK: query: create table testctas2 as select * from testctas1 where 1=2 +PREHOOK: type: CREATETABLE_AS_SELECT +PREHOOK: Input: default@testctas1 +PREHOOK: Output: database:default +PREHOOK: Output: default@testctas2 +POSTHOOK: query: create table testctas2 as select * from testctas1 where 1=2 +POSTHOOK: type: CREATETABLE_AS_SELECT +POSTHOOK: Input: default@testctas1 +POSTHOOK: Output: database:default +POSTHOOK: Output: default@testctas2 +POSTHOOK: Lineage: testctas2.id SIMPLE [(testctas1)testctas1.FieldSchema(name:id, type:int, comment:null), ]