davidm-db commented on code in PR #47442:
URL: https://github.com/apache/spark/pull/47442#discussion_r1687926613
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -175,10 +175,22 @@ class AstBuilder extends DataTypeAstBuilder with
SQLConfHelper with Logging {
.map { s =>
SingleStatement(parsedPlan = visit(s).asInstanceOf[LogicalPlan])
}.getOrElse {
-
visit(ctx.beginEndCompoundBlock()).asInstanceOf[CompoundPlanStatement]
+ visitChildren(ctx).asInstanceOf[CompoundPlanStatement]
}
}
+ override def visitIfElseStatement(ctx: IfElseStatementContext):
IfElseStatement = {
+ IfElseStatement(
+ conditions = ctx.booleanExpression().asScala.toList.map(boolExpr =>
withOrigin(boolExpr) {
Review Comment:
is there an easy way to evaluate boolean expression (except what we did here
- wrapping inside of a `Project`)?
the reason why we did it like this, as I explained in the other comment, is
because we want to be able to iterate through the condition as well, and this
approach is complicated a bit if the condition is not an instance of
`SingleStatement`.
if we need to wrap expression into something similar to what we did here to
evaluate it properly, I don't see a reason not to do it immediately and then
use the logical plan to construct the `SingleStatement`, as we did here.
but, as I said, depends a bit on whether there is a better way to evaluate
boolean expressions?
--
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]