dusantism-db commented on code in PR #47672:
URL: https://github.com/apache/spark/pull/47672#discussion_r1709734161
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -229,6 +229,31 @@ class AstBuilder extends DataTypeAstBuilder
)
}
+ override def visitSearchedCaseStatement(ctx: SearchedCaseStatementContext)
+ : SearchedCaseStatement = {
+ SearchedCaseStatement(
+ conditions = ctx.conditions.asScala.toList.map(boolExpr =>
withOrigin(boolExpr) {
+ SingleStatement(
+ Project(
+ Seq(Alias(expression(boolExpr), "condition")()),
+ OneRowRelation()))
+ }),
+ conditionalBodies = ctx.conditionalBodies.asScala.toList.map(body =>
visitCompoundBody(body)),
+ elseBody = Option(ctx.elseBody).map(body => visitCompoundBody(body)))
+ }
+
+ override def visitSimpleCaseStatement(ctx: SimpleCaseStatementContext):
SearchedCaseStatement = {
Review Comment:
Simple case statements are currently parsed to searched case statements,
which is probably suboptimal because the main case expression (caseVariable)
will be evaluated multiple times.
--
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]