This is an automated email from the ASF dual-hosted git repository.

lgbo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 5e1db37c6 [GLUTEN-7220][CH]Fix expand bug in grouping sets query 
(#7221)
5e1db37c6 is described below

commit 5e1db37c62106f38a46692a349e0f6b9bff0767a
Author: kevinyhzou <[email protected]>
AuthorDate: Wed Sep 18 14:13:04 2024 +0800

    [GLUTEN-7220][CH]Fix expand bug in grouping sets query (#7221)
    
    * fix grouping set
    
    * remove useless code
---
 .../execution/hive/GlutenClickHouseHiveTableSuite.scala      |  1 +
 .../tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala      | 12 ++++++++++++
 cpp-ch/local-engine/Operator/DefaultHashAggregateResult.cpp  |  2 +-
 cpp-ch/local-engine/Operator/ExpandStep.cpp                  |  2 +-
 cpp-ch/local-engine/Operator/ExpandTransform.cpp             |  6 +++---
 .../Operator/{ExpandTransorm.h => ExpandTransform.h}         |  0
 6 files changed, 18 insertions(+), 5 deletions(-)

diff --git 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/hive/GlutenClickHouseHiveTableSuite.scala
 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/hive/GlutenClickHouseHiveTableSuite.scala
index b16ae3c11..6778dccd3 100644
--- 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/hive/GlutenClickHouseHiveTableSuite.scala
+++ 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/hive/GlutenClickHouseHiveTableSuite.scala
@@ -1415,4 +1415,5 @@ class GlutenClickHouseHiveTableSuite
     runQueryAndCompare(selectSql)(df => 
checkOperatorCount[ProjectExecTransformer](3)(df))
     spark.sql("DROP TABLE test_tbl_7054")
   }
+
 }
diff --git 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
index 9ac35441a..0536d9136 100644
--- 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
+++ 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala
@@ -2991,5 +2991,17 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends 
GlutenClickHouseTPCHAbstr
       checkGlutenOperatorMatch[ProjectExecTransformer]
     }
   }
+
+  test("GLUTEN-7220: Fix bug of grouping sets") {
+    val table_create_sql = "create table test_tbl_7220(id bigint, name string) 
using parquet"
+    val insert_data_sql = "insert into test_tbl_7220 values(1, 'a123'), (2, 
'a124'), (3, 'a125')"
+    val query_sql = "select '2024-08-26' as day, id,name from" +
+      " (select id, name from test_tbl_7220 group by id, name grouping 
sets((id),(id,name))) " +
+      " where name  = 'a124'"
+    spark.sql(table_create_sql)
+    spark.sql(insert_data_sql)
+    compareResultsAgainstVanillaSpark(query_sql, true, { _ => })
+    spark.sql("drop table test_tbl_7220")
+  }
 }
 // scalastyle:on line.size.limit
diff --git a/cpp-ch/local-engine/Operator/DefaultHashAggregateResult.cpp 
b/cpp-ch/local-engine/Operator/DefaultHashAggregateResult.cpp
index fa8d51aee..3c5450f74 100644
--- a/cpp-ch/local-engine/Operator/DefaultHashAggregateResult.cpp
+++ b/cpp-ch/local-engine/Operator/DefaultHashAggregateResult.cpp
@@ -22,7 +22,7 @@
 #include <Core/ColumnsWithTypeAndName.h>
 #include <DataTypes/DataTypeNullable.h>
 #include <DataTypes/DataTypesNumber.h>
-#include <Operator/ExpandTransorm.h>
+#include <Operator/ExpandTransform.h>
 #include <Processors/Chunk.h>
 #include <Processors/IProcessor.h>
 #include <Processors/Transforms/AggregatingTransform.h>
diff --git a/cpp-ch/local-engine/Operator/ExpandStep.cpp 
b/cpp-ch/local-engine/Operator/ExpandStep.cpp
index 8770c4c40..518f094cd 100644
--- a/cpp-ch/local-engine/Operator/ExpandStep.cpp
+++ b/cpp-ch/local-engine/Operator/ExpandStep.cpp
@@ -22,7 +22,7 @@
 #include <Core/ColumnsWithTypeAndName.h>
 #include <DataTypes/DataTypeNullable.h>
 #include <DataTypes/DataTypesNumber.h>
-#include <Operator/ExpandTransorm.h>
+#include <Operator/ExpandTransform.h>
 #include <Processors/IProcessor.h>
 #include <QueryPipeline/Pipe.h>
 #include <QueryPipeline/QueryPipelineBuilder.h>
diff --git a/cpp-ch/local-engine/Operator/ExpandTransform.cpp 
b/cpp-ch/local-engine/Operator/ExpandTransform.cpp
index 29e254bc0..a3192dbf5 100644
--- a/cpp-ch/local-engine/Operator/ExpandTransform.cpp
+++ b/cpp-ch/local-engine/Operator/ExpandTransform.cpp
@@ -27,7 +27,7 @@
 #include <Common/Exception.h>
 #include <Common/logger_useful.h>
 
-#include "ExpandTransorm.h"
+#include "ExpandTransform.h"
 
 namespace DB
 {
@@ -122,8 +122,8 @@ void ExpandTransform::work()
         else if (kind == EXPAND_FIELD_KIND_LITERAL)
         {
             /// Add const column with field value
-            auto column = type->createColumnConst(rows, field);
-            columns[col_i] = column;
+            auto column = type->createColumnConst(rows, 
field)->convertToFullColumnIfConst();
+            columns[col_i] = std::move(column);
         }
         else
             throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Unknown 
ExpandFieldKind {}", magic_enum::enum_name(kind));
diff --git a/cpp-ch/local-engine/Operator/ExpandTransorm.h 
b/cpp-ch/local-engine/Operator/ExpandTransform.h
similarity index 100%
rename from cpp-ch/local-engine/Operator/ExpandTransorm.h
rename to cpp-ch/local-engine/Operator/ExpandTransform.h


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to