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


##########
backends-velox/src-delta4/main/scala/org/apache/spark/sql/delta/stats/GlutenDeltaJobStatsTracker.scala:
##########
@@ -72,13 +74,31 @@ private[stats] class GlutenDeltaJobStatsTracker(val 
delegate: DeltaJobStatistics
   private val dataCols = delegate.dataCols
   private val statsColExpr = delegate.statsColExpr
 
-  private val srlHadoopConf = new SerializableConfiguration(hadoopConf)
   private val rootUri = 
path.getFileSystem(hadoopConf).makeQualified(path).toUri
 
   override def newTaskInstance(): WriteTaskStatsTracker = {
-    val rootPath = new Path(rootUri)
-    val hadoopConf = srlHadoopConf.value
-    new GlutenDeltaTaskStatsTracker(dataCols, statsColExpr, rootPath, 
hadoopConf)
+    val aggregates = statsColExpr.collect {
+      case ae: AggregateExpression if 
ae.aggregateFunction.isInstanceOf[DeclarativeAggregate] =>
+        assert(ae.mode == Complete)
+        ae
+    }
+    val plan = createStatsPlan(dataCols, aggregates)
+    plan match {
+      case WholeStageTransformer(child: TransformSupport, _) if 
supportsNativeStats(child) =>
+        if (Utils.isTesting) {
+          statsPlanObserver.foreach(_(new Path(rootUri), child))
+        }
+        new GlutenDeltaTaskStatsTracker(statsColExpr, aggregates, child)
+      case _ =>
+        val reasons = plan
+          .flatMap(node => FallbackTags.getOption(node).map(_.reason()))
+          .distinct
+          .mkString("; ")
+        logWarning(
+          "Gluten Delta: Statistics plan could not be fully offloaded. Falling 
back to " +
+            s"row-based Delta statistics with columnar-to-row conversion. 
$reasons")

Review Comment:
   Would you help check whether there is any duplicated code or existing API in 
the code base for similar purpose? Which obtains fallback reason from a query 
plan? 



-- 
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