You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by ex...@apache.org on 2024/11/14 12:01:20 UTC
(incubator-gluten) branch main updated: [GLUTEN-7647][CH] Drop literals in aggregation results (#7951)
This is an automated email from the ASF dual-hosted git repository.
exmy 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 7b40050554 [GLUTEN-7647][CH] Drop literals in aggregation results (#7951)
7b40050554 is described below
commit 7b4005055408b7cbdc4f5e9bec5b6ac442e52259
Author: lgbo <lg...@gmail.com>
AuthorDate: Thu Nov 14 20:01:16 2024 +0800
[GLUTEN-7647][CH] Drop literals in aggregation results (#7951)
---
.../apache/gluten/extension/LazyAggregateExpandRule.scala | 13 +++++++++++--
.../tpch/GlutenClickHouseTPCHSaltNullParquetSuite.scala | 8 ++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/backends-clickhouse/src/main/scala/org/apache/gluten/extension/LazyAggregateExpandRule.scala b/backends-clickhouse/src/main/scala/org/apache/gluten/extension/LazyAggregateExpandRule.scala
index d64300a12f..0f77523397 100644
--- a/backends-clickhouse/src/main/scala/org/apache/gluten/extension/LazyAggregateExpandRule.scala
+++ b/backends-clickhouse/src/main/scala/org/apache/gluten/extension/LazyAggregateExpandRule.scala
@@ -345,8 +345,17 @@ case class LazyAggregateExpandRule(session: SparkSession) extends Rule[SparkPlan
s"groupingExpressions: ${partialAggregate.groupingExpressions}")
// Remove group id column from result expressions
- val resultExpressions = partialAggregate.resultExpressions
- .filter(!_.toAttribute.semanticEquals(groupIdAttribute))
+ val groupingKeysCount =
+ partialAggregate.resultExpressions.length - partialAggregate.aggregateExpressions.length
+ var resultExpressions = partialAggregate.resultExpressions
+ .slice(0, groupingKeysCount)
+ .filter(
+ e =>
+ !e.toAttribute.semanticEquals(groupIdAttribute) &&
+ attributesToReplace.find(kv => kv._1.semanticEquals(e.toAttribute)).isDefined)
+ .map(e => getReplaceAttribute(e.toAttribute, attributesToReplace))
+ resultExpressions = resultExpressions ++ partialAggregate.resultExpressions
+ .slice(groupingKeysCount, partialAggregate.resultExpressions.length)
.map(e => getReplaceAttribute(e.toAttribute, attributesToReplace))
logDebug(
s"xxx newResultExpressions: $resultExpressions\n" +
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 9affdeb7f7..865d3fa40c 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
@@ -3066,6 +3066,14 @@ class GlutenClickHouseTPCHSaltNullParquetSuite extends GlutenClickHouseTPCHAbstr
|order by n_regionkey, n_nationkey
|""".stripMargin
compareResultsAgainstVanillaSpark(sql, true, checkLazyExpand)
+
+ sql = """
+ |select x, n_regionkey, n_nationkey,
+ |sum(n_regionkey), count(n_name), max(n_regionkey), min(n_regionkey)
+ |from (select '123' as x, * from nation) group by x, n_regionkey, n_nationkey with cube
+ |order by x, n_regionkey, n_nationkey
+ |""".stripMargin
+ compareResultsAgainstVanillaSpark(sql, true, checkLazyExpand)
}
test("GLUTEN-7647 lazy expand for avg and sum") {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org