davidm-db commented on code in PR #47672:
URL: https://github.com/apache/spark/pull/47672#discussion_r1739369364
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -247,6 +247,33 @@ class AstBuilder extends DataTypeAstBuilder
WhileStatement(condition, body, Some(labelText))
}
+ 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 = {
+ // uses EqualTo to compare the case variable(the main case expression)
+ // to the WHEN clause expressions
+ SearchedCaseStatement(
+ conditions = ctx.conditionExpressions.asScala.toList.map(expr =>
withOrigin(expr) {
+ SingleStatement(
+ Project(
+ Seq(Alias(EqualTo(expression(ctx.caseVariable),
expression(expr)), "condition")()),
+ OneRowRelation()))
Review Comment:
nit: indentation, two spaces less
--
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]