You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by ta...@apache.org on 2026/07/01 11:30:41 UTC
(gluten) 10/38: [GLUTEN][CORE] Add backend hook for sort aggregate offload
This is an automated email from the ASF dual-hosted git repository.
taiyang-li pushed a commit to branch fake_add_bolt_backend
in repository https://gitbox.apache.org/repos/asf/gluten.git
commit 90e224a833580f4673559be742e0412e83de1df0
Author: liyang.127 <li...@bytedance.com>
AuthorDate: Sat Jun 27 21:18:02 2026 +0800
[GLUTEN][CORE] Add backend hook for sort aggregate offload
---
.../org/apache/gluten/backendsapi/SparkPlanExecApi.scala | 11 +++++++++++
.../extension/columnar/offload/OffloadSingleNodeRules.scala | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gluten-substrait/src/main/scala/org/apache/gluten/backendsapi/SparkPlanExecApi.scala b/gluten-substrait/src/main/scala/org/apache/gluten/backendsapi/SparkPlanExecApi.scala
index 79f3d67c0e..ee347c183e 100644
--- a/gluten-substrait/src/main/scala/org/apache/gluten/backendsapi/SparkPlanExecApi.scala
+++ b/gluten-substrait/src/main/scala/org/apache/gluten/backendsapi/SparkPlanExecApi.scala
@@ -37,6 +37,7 @@ import org.apache.spark.sql.catalyst.optimizer.BuildSide
import org.apache.spark.sql.catalyst.plans.JoinType
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, Partitioning}
import org.apache.spark.sql.execution._
+import org.apache.spark.sql.execution.aggregate.BaseAggregateExec
import org.apache.spark.sql.execution.datasources.FileFormat
import org.apache.spark.sql.execution.exchange.ShuffleExchangeExec
import org.apache.spark.sql.execution.joins.BuildSideRelation
@@ -102,6 +103,16 @@ trait SparkPlanExecApi {
resultExpressions,
child)
+ /**
+ * Offload a [[org.apache.spark.sql.execution.aggregate.SortAggregateExec]] to a columnar
+ * transformer. By default it goes through [[HashAggregateExecBaseTransformer.fromSortAggregate]]
+ * so that the result is tagged as a sort-based aggregate (used by sort elimination rules).
+ * Backends that do not need the sort-based semantic can override this to fall back to a regular
+ * hash aggregate transformer.
+ */
+ def offloadSortAggregate(plan: BaseAggregateExec): HashAggregateExecBaseTransformer =
+ HashAggregateExecBaseTransformer.fromSortAggregate(plan)
+
/** Generate HashAggregateExecPullOutHelper */
def genHashAggregateExecPullOutHelper(
aggregateExpressions: Seq[AggregateExpression],
diff --git a/gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/offload/OffloadSingleNodeRules.scala b/gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/offload/OffloadSingleNodeRules.scala
index 3d844607b3..19c2fc40e7 100644
--- a/gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/offload/OffloadSingleNodeRules.scala
+++ b/gluten-substrait/src/main/scala/org/apache/gluten/extension/columnar/offload/OffloadSingleNodeRules.scala
@@ -215,7 +215,7 @@ object OffloadOthers {
case plan: HashAggregateExec =>
HashAggregateExecBaseTransformer.from(plan)
case plan: SortAggregateExec =>
- HashAggregateExecBaseTransformer.fromSortAggregate(plan)
+ BackendsApiManager.getSparkPlanExecApiInstance.offloadSortAggregate(plan)
case plan: ObjectHashAggregateExec =>
HashAggregateExecBaseTransformer.from(plan)
case plan: UnionExec =>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org