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 faa1efb295 fix (#8999)
faa1efb295 is described below

commit faa1efb2951868f739bb5f6ea0c663aa926bcfc1
Author: kevinyhzou <[email protected]>
AuthorDate: Tue Mar 18 18:02:05 2025 +0800

    fix (#8999)
---
 .../execution/tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala   | 6 ++++++
 cpp-ch/local-engine/AggregateFunctions/GroupLimitFunctions.cpp      | 1 -
 cpp-ch/local-engine/Parser/RelParsers/GroupLimitRelParser.cpp       | 5 +++--
 3 files changed, 9 insertions(+), 3 deletions(-)

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 c30577c339..3ce03565e8 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
@@ -3390,5 +3390,11 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends 
GlutenClickHouseTPCHAbstr
     spark.sql("drop table test_tbl_8343")
   }
 
+  test("GLUTEN-8995: Fix column not found in row_number") {
+    val select_sql =
+      "select  id from (select id ,row_number() over (partition by id order by 
id desc) as rank from range(1)) c1 where  rank =1"
+    compareResultsAgainstVanillaSpark(select_sql, true, { _ => })
+  }
+
 }
 // scalastyle:on line.size.limit
diff --git a/cpp-ch/local-engine/AggregateFunctions/GroupLimitFunctions.cpp 
b/cpp-ch/local-engine/AggregateFunctions/GroupLimitFunctions.cpp
index 67c9e8380a..20ef632ee6 100644
--- a/cpp-ch/local-engine/AggregateFunctions/GroupLimitFunctions.cpp
+++ b/cpp-ch/local-engine/AggregateFunctions/GroupLimitFunctions.cpp
@@ -271,7 +271,6 @@ private:
                     DB::ErrorCodes::BAD_ARGUMENTS, "Not found column {} in 
tuple {}", ident_name, argument_types[0]->getName());
             }
             field.pos = std::distance(tuple_element_names.begin(), name_pos);
-
             fields.push_back(field);
         }
         return fields;
diff --git a/cpp-ch/local-engine/Parser/RelParsers/GroupLimitRelParser.cpp 
b/cpp-ch/local-engine/Parser/RelParsers/GroupLimitRelParser.cpp
index 597d90adaa..468a9a26f5 100644
--- a/cpp-ch/local-engine/Parser/RelParsers/GroupLimitRelParser.cpp
+++ b/cpp-ch/local-engine/Parser/RelParsers/GroupLimitRelParser.cpp
@@ -267,9 +267,10 @@ void 
AggregateGroupLimitRelParser::prePrejectionForAggregateArguments(DB::QueryP
 {
     auto projection_actions = 
std::make_shared<DB::ActionsDAG>(input_header.getColumnsWithTypeAndName());
 
-
     auto partition_fields = 
parsePartitionFields(win_rel_def->partition_expressions());
+    auto sort_fields = parseSortFields(win_rel_def->sorts());
     std::set<size_t> unique_partition_fields(partition_fields.begin(), 
partition_fields.end());
+    std::set<size_t> unique_sort_fields(sort_fields.begin(), 
sort_fields.end());
     DB::NameSet required_column_names;
     auto build_tuple = [&](const DB::DataTypes & data_types,
                            const Strings & names,
@@ -295,7 +296,7 @@ void 
AggregateGroupLimitRelParser::prePrejectionForAggregateArguments(DB::QueryP
     for (size_t i = 0; i < input_header.columns(); ++i)
     {
         const auto & col = input_header.getByPosition(i);
-        if (unique_partition_fields.count(i))
+        if (unique_partition_fields.count(i) && !unique_sort_fields.count(i))
         {
             required_column_names.insert(col.name);
             aggregate_grouping_keys.push_back(col.name);


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

Reply via email to