cloud-fan commented on a change in pull request #30807:
URL: https://github.com/apache/spark/pull/30807#discussion_r549609445



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -1195,27 +1208,46 @@ case class NextDay(startDate: Expression, dayOfWeek: 
Expression)
     nullSafeCodeGen(ctx, ev, (sd, dowS) => {
       val dateTimeUtilClass = DateTimeUtils.getClass.getName.stripSuffix("$")
       val dayOfWeekTerm = ctx.freshName("dayOfWeek")
+      val failOnErrorTerm = ctx.freshName("failOnError")
       if (dayOfWeek.foldable) {
         val input = dayOfWeek.eval().asInstanceOf[UTF8String]
-        if ((input eq null) || DateTimeUtils.getDayOfWeekFromString(input) == 
-1) {
+        if (input eq null) {
+          s"""${ev.isNull} = true;"""
+        } else if (DateTimeUtils.getDayOfWeekFromString(input) == -1) {
+          val errMsg = input.replace(
+            UTF8String.fromString("""""""), UTF8String.fromString("""\""""))
           s"""
-             |${ev.isNull} = true;
-           """.stripMargin
+             |boolean $failOnErrorTerm = $failOnError;
+             |if ($failOnErrorTerm) {

Review comment:
       can we follow other expressions? We don't need to generate `if-else` in 
the code, as we know the value of `failOnError` before generating the code.




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

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