davidm-db commented on code in PR #47442:
URL: https://github.com/apache/spark/pull/47442#discussion_r1695117327


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/SqlScriptingLogicalOperators.scala:
##########
@@ -58,3 +58,13 @@ case class SingleStatement(parsedPlan: LogicalPlan)
 case class CompoundBody(
     collection: Seq[CompoundPlanStatement],
     label: Option[String]) extends CompoundPlanStatement
+
+/**
+ * Logical operator for IF ELSE statement.
+ * @param conditions Collection of conditions. First condition corresponds to 
IF clause,
+ *                   while others (if any) correspond to following ELSE IF 
clauses.
+ * @param bodies Collection of bodies.
+ */
+case class IfElseStatement(
+    conditions: Seq[SingleStatement],
+    bodies: Seq[CompoundBody]) extends CompoundPlanStatement

Review Comment:
   I added the assert to the execution node, but it makes sense to add it here 
as well.
   
   Regarding the `else` branch, should I change everything then to have IF, 
ELSE IF and ELSE bodies as separate parameters. What you suggested is somewhere 
in between in my opinion.
   
   The current approach simplifies iteration in execution node a lot. If we 
were to separate things we would need to have more internal states and it would 
be harder to figure out which condition/body to reference. Currently, we just 
rely on the internal counter to iterate through all the conditions and based on 
the condition index we know which body to reference.
   
   I have nothing against changing this though, these are just my thoughts.



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