philo-he commented on code in PR #12703:
URL: https://github.com/apache/gluten/pull/12703#discussion_r3818697380
##########
gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenExplainUtils.scala:
##########
@@ -45,6 +45,36 @@ import scala.collection.mutable.{ArrayBuffer, BitSet}
object GlutenExplainUtils extends AdaptiveSparkPlanHelper {
type FallbackInfo = (Int, Map[String, String])
+ /**
+ * Returns whether a plan should be ignored when collecting fallback
statistics.
+ *
+ * Such plans are structural wrappers rather than execution operators: they
are neither fallback
+ * Spark operators nor native Gluten operators.
+ */
+ def isFallbackInsensitivePlan(plan: SparkPlan): Boolean = plan match {
+ case _: ExecutedCommandExec => true
+ case _: CommandResultExec => true
+ case p: V2CommandExec =>
+ !FallbackTags.nonEmpty(p) &&
p.logicalLink.forall(FallbackTags.getOption(_).isEmpty)
+ case _: DataWritingCommandExec => true
+ case _: WholeStageCodegenExec => true
+ case _: WholeStageTransformer => true
+ case _: InputAdapter => true
+ case _: ColumnarInputAdapter => true
+ case _: InputIteratorTransformer => true
+ case _: ColumnarToRowTransition => true
+ case _: RowToColumnarTransition => true
+ case _: ReusedExchangeExec => true
+ case _: NoopLeaf => true
+ case w: WriteFilesExec => w.child.isInstanceOf[NoopLeaf]
+ case _: AdaptiveSparkPlanExec => true
+ case _: QueryStageExec => true
+ case _: AQEShuffleReadExec => true
+ case _: ColumnarAQEShuffleReadExec => true
+ case i: InMemoryTableScanExec => PlanUtil.isGlutenTableCache(i)
Review Comment:
I think this Gluten InMemoryTableScanExec shouldn't be viewed as
FallbackInsensitive plan. And I notice it is already included as a case in
`GlutenExplainUtils.scala`.
##########
gluten-substrait/src/main/scala/org/apache/spark/sql/execution/GlutenExplainUtils.scala:
##########
@@ -45,6 +45,36 @@ import scala.collection.mutable.{ArrayBuffer, BitSet}
object GlutenExplainUtils extends AdaptiveSparkPlanHelper {
type FallbackInfo = (Int, Map[String, String])
+ /**
+ * Returns whether a plan should be ignored when collecting fallback
statistics.
+ *
+ * Such plans are structural wrappers rather than execution operators: they
are neither fallback
+ * Spark operators nor native Gluten operators.
+ */
+ def isFallbackInsensitivePlan(plan: SparkPlan): Boolean = plan match {
Review Comment:
I note some cases are not really structural nodes. If we'd like to make this
method only focus on structural node check, the proposed method name would be
`isStructuralPlanNode` for easily understanding.
In addition, we should move the following non-structural nodes to the caller
side checking, e.g. let the visit method ignore them directly (or
conditionally depending on the if condition).
```
ExecutedCommandExec, CommandResultExec, DataWritingCommandExec,
V2CommandExec, WriteFilesExec,
AQEShuffleReadExec, ColumnarAQEShuffleReadExec and InMemoryTableScanExec
```
--
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]