zhztheplayer commented on code in PR #13510:
URL: https://github.com/apache/gluten/pull/13510#discussion_r4603179799


##########
backends-velox/src-delta33/main/scala/org/apache/spark/sql/delta/stats/GlutenDeltaJobStatsTracker.scala:
##########
@@ -115,12 +137,46 @@ object GlutenDeltaJobStatsTracker extends Logging {
       new GlutenDeltaJobStatsFallbackTracker(tracker)
   }
 
+  private def createStatsPlan(
+      dataCols: Seq[Attribute],
+      aggregates: Seq[AggregateExpression]): SparkPlan = {
+    val statsAttrs = 
aggregates.flatMap(_.aggregateFunction.aggBufferAttributes)
+    val statsResultAttrs = 
aggregates.flatMap(_.aggregateFunction.inputAggBufferAttributes)
+    val aggOp = SortAggregateExec(
+      None,
+      isStreaming = false,
+      None,
+      Seq.empty,
+      aggregates,
+      statsAttrs,
+      0,
+      statsResultAttrs,
+      StatisticsInputNode(dataCols)
+    )
+    val projOp = ProjectExec(statsResultAttrs, aggOp)
+    val offloads = Seq(OffloadOthers()).map(_.toStrcitRule())
+    val validatorBuilder: GlutenConfig => Validator = conf =>
+      Validators.newValidator(conf, offloads)
+    val config = GlutenConfig.get
+    val transformRule =
+      HeuristicTransform.WithRewrites(validatorBuilder(config), 
Seq(PullOutPreProject), offloads)
+    ColumnarCollapseTransformStages(config)(transformRule(projOp))

Review Comment:
   What's the main reason of the fallbacks? The statistics plan should be in a 
few fixed patterns - can we just support them or have more focused checks?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to