LuciferYang commented on code in PR #56218:
URL: https://github.com/apache/spark/pull/56218#discussion_r3329956258


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -1359,21 +1357,35 @@ abstract class ToTimestamp
     } else {
       s"/ $downScaleFactor"
     }
+    // Emits the string -> timestamp parse body. The ANSI (failOnError) branch
+    // delegates the parse and the parse-error -> ANSI error translation to
+    // DateTimeExpressionUtils.parseToTimestampExact, collapsing the inline
+    // try/catch to a single call. The non-ANSI branch keeps the inline
+    // try/catch that maps a parse failure to a null result.
+    def parseTimestampCode(formatterExpr: String, inputExpr: String): String = 
{
+      if (failOnError) {
+        s"""${ev.value} = $utils.parseToTimestampExact(""" +
+          s"""$formatterExpr, $inputExpr, ${downScaleFactor}L, 
$forTimestampNTZ, """ +
+          s""""$suggestedFuncOnFail");"""

Review Comment:
   ```
   s"""${ev.value} = $utils.parseToTimestampExact(
       |    $formatterExpr, $inputExpr, ${downScaleFactor}L,
       |    $forTimestampNTZ, "$suggestedFuncOnFail");""".stripMargin
    ```



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