dejankrak-db commented on code in PR #49726:
URL: https://github.com/apache/spark/pull/49726#discussion_r1946757039


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -288,6 +288,42 @@ class AstBuilder extends DataTypeAstBuilder
     ExceptionHandler(exceptionHandlerTriggers, body, handlerType)
   }
 
+  override def visitSignalStatementWithCondition(
+      ctx: SignalStatementWithConditionContext): SignalStatement = {
+    val messageString = Option(ctx.msgStr)
+      .map(sl => Left(string(visitStringLit(sl)).replace("'", "")))
+    val messageVariable = Option(ctx.msgVar)
+      .map(mpi => Right(UnresolvedAttribute(visitMultipartIdentifier(mpi))))
+    val messageArguments = Option(ctx.argVar)
+      .map(mpi => UnresolvedAttribute(visitMultipartIdentifier(mpi)))
+
+    SignalStatement(
+      errorCondition = 
Some(ctx.conditionName.getText.toUpperCase(Locale.ROOT)),
+      sqlState = None,
+      message = messageVariable.getOrElse(messageString.getOrElse(Left(""))),
+      messageArguments = messageArguments
+    )
+  }
+
+  override def visitSignalStatementWithSqlState(
+      ctx: SignalStatementWithSqlStateContext): SignalStatement = {
+    val sqlState = visitStringLit(ctx.sqlState).getText.replace("'", "")

Review Comment:
   For the string operations in this method, it would improve readability to 
add comments how/why we are parsing parts of the context to fetch SQL state, 
message string and variable, and use them to build signal statement.



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