From 780e8f496bb29252c2cea0466ebd3c9a5a535e05 Mon Sep 17 00:00:00 2001 From: yikaifei Date: Thu, 7 Nov 2024 16:04:08 +0800 Subject: [PATCH] native writer support CreateHiveTableAsSelectCommand --- .../sql/execution/VeloxParquetWriteForHiveSuite.scala | 9 +++++++++ .../datasources/GlutenWriterColumnarRules.scala | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteForHiveSuite.scala b/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteForHiveSuite.scala index 412548de9c44..f880945b4ac3 100644 --- a/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteForHiveSuite.scala +++ b/backends-velox/src/test/scala/org/apache/spark/sql/execution/VeloxParquetWriteForHiveSuite.scala @@ -176,4 +176,13 @@ class VeloxParquetWriteForHiveSuite extends GlutenQueryTest with SQLTestUtils { checkAnswer(sql("SELECT * FROM t"), Row(1)) } } + + test("native writer support CreateHiveTableAsSelectCommand") { + withTable("t", "t2") { + withSQLConf("spark.sql.hive.convertMetastoreParquet" -> "false") { + checkNativeWrite("CREATE TABLE t STORED AS PARQUET AS SELECT 1 as c", checkNative = true) + } + checkAnswer(spark.table("t"), Row(1)) + } + } } diff --git a/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/datasources/GlutenWriterColumnarRules.scala b/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/datasources/GlutenWriterColumnarRules.scala index d33e779eb332..917f6c03dfe0 100644 --- a/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/datasources/GlutenWriterColumnarRules.scala +++ b/gluten-substrait/src/main/scala/org/apache/spark/sql/execution/datasources/GlutenWriterColumnarRules.scala @@ -121,8 +121,10 @@ object GlutenWriterColumnarRules { command.table.storage.outputFormat .flatMap(formatMapping.get) .filter(GlutenFormatFactory.isRegistered) - case _: CreateHiveTableAsSelectCommand => - None + case command: CreateHiveTableAsSelectCommand => + command.tableDesc.storage.outputFormat + .flatMap(formatMapping.get) + .filter(GlutenFormatFactory.isRegistered) case _ => None }