zhztheplayer commented on code in PR #7582:
URL: https://github.com/apache/incubator-gluten/pull/7582#discussion_r1805857582


##########
gluten-core/src/main/scala/org/apache/gluten/extension/GlutenColumnarRule.scala:
##########
@@ -109,16 +77,31 @@ case class GlutenColumnarRule(
    */
   final override def preColumnarTransitions: Rule[SparkPlan] = plan => {
     // To infer caller's property: 
ApplyColumnarRulesAndInsertTransitions#outputsColumnar.
-    OutputsColumnarTester.wrap(plan)
+    if (plan.supportsColumnar) {
+      DummyColumnarOutputExec(plan)
+    } else {
+      DummyRowOutputExec(plan)
+    }
   }
 
   override def postColumnarTransitions: Rule[SparkPlan] = plan => {
-    val outputsColumnar = OutputsColumnarTester.inferOutputsColumnar(plan)
-    val unwrapped = OutputsColumnarTester.unwrap(plan)
-    val vanillaPlan = Transitions.insertTransitions(unwrapped, outputsColumnar)
+    val (childPlan, outputsColumnar) = plan match {
+      case DummyRowOutputExec(child) =>
+        (child, false)
+      case RowToColumnarExec(DummyRowOutputExec(child)) =>
+        (child, true)
+      case DummyColumnarOutputExec(child) =>
+        (child, true)
+      case ColumnarToRowExec(DummyColumnarOutputExec(child)) =>
+        (child, false)
+      case _ =>
+        throw new IllegalStateException(
+          "This should not happen. Please leave a issue at" +
+            " https://github.com/apache/incubator-gluten.";)
+    }
+    val vanillaPlan = Transitions.insertTransitions(childPlan, outputsColumnar)
     val applier = applierBuilder.apply(session)
-    val out = applier.apply(vanillaPlan, outputsColumnar)
-    out
+    applier.apply(vanillaPlan, outputsColumnar)

Review Comment:
   ```scala
   val out = ...
   out
   ```
   
   This code pattern is used usually because `out` allows developer to place a 
breakpoint for debugging against the output object easily. Do you happen to 
know an alternative way if we simplify the code?



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