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

changchen 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 caf6cb208b [GLUTEN-7596][CH] Fix bnlj empty join error(#7597)
caf6cb208b is described below

commit caf6cb208b8f465be7a47d3e2368af4d2ffef12e
Author: Shuai li <[email protected]>
AuthorDate: Mon Oct 21 10:40:12 2024 +0800

    [GLUTEN-7596][CH] Fix bnlj empty join error(#7597)
---
 .../tpch/GlutenClickHouseTPCHParquetRFSuite.scala  | 24 ++++++++++++++++++++++
 cpp-ch/local-engine/Join/BroadCastJoinBuilder.cpp  | 15 ++++----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHParquetRFSuite.scala
 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHParquetRFSuite.scala
index 3dca8c11fd..b78a1cd364 100644
--- 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHParquetRFSuite.scala
+++ 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/tpch/GlutenClickHouseTPCHParquetRFSuite.scala
@@ -71,4 +71,28 @@ class GlutenClickHouseTPCHParquetRFSuite extends 
GlutenClickHouseTPCHSaltNullPar
       )
     }
   }
+
+  test("GLUTEN-7596: Empty list of columns passed") {
+    val sql_str =
+      s"""
+         |SELECT
+         |    l_orderkey,
+         |    count(*) cnt
+         |FROM lineitem inner join
+         |    (
+         |    select * from (
+         |    select count(*) cct,o_orderkey from orders group by o_orderkey)
+         |    where cct > 10000
+         |    )
+         |GROUP BY
+         |    l_orderkey
+         |ORDER BY
+         |    l_orderkey
+         |LIMIT 10;
+         |""".stripMargin
+
+    withSQLConf("spark.sql.adaptive.enabled" -> "false") {
+      compareResultsAgainstVanillaSpark(sql_str, compareResult = true, _ => {})
+    }
+  }
 }
diff --git a/cpp-ch/local-engine/Join/BroadCastJoinBuilder.cpp 
b/cpp-ch/local-engine/Join/BroadCastJoinBuilder.cpp
index bccdbded51..2191a3bee7 100644
--- a/cpp-ch/local-engine/Join/BroadCastJoinBuilder.cpp
+++ b/cpp-ch/local-engine/Join/BroadCastJoinBuilder.cpp
@@ -141,21 +141,14 @@ std::shared_ptr<StorageJoinFromReadBuffer> buildJoin(
     Blocks data;
     auto collect_data = [&]
     {
-        bool header_empty = header.getNamesAndTypesList().empty();
-        bool only_one_column = header_empty;
+        bool only_one_column = header.getNamesAndTypesList().empty();
+        if (only_one_column)
+            header = 
BlockUtil::buildRowCountBlock(0).getColumnsWithTypeAndName();
+
         NativeReader block_stream(input);
         ProfileInfo info;
         while (Block block = block_stream.read())
         {
-            if (header_empty)
-            {
-                // In bnlj, buidside output maybe empty,
-                //   we use buildside header only for loop
-                // Like: select count(*) from t1 left join t2
-                header = resetBuildTableBlockName(block, true);
-                header_empty = false;
-            }
-
             DB::ColumnsWithTypeAndName columns;
             for (size_t i = 0; i < block.columns(); ++i)
             {


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

Reply via email to