cloud-fan commented on code in PR #45822:
URL: https://github.com/apache/spark/pull/45822#discussion_r1548924394


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala:
##########
@@ -1235,11 +1235,13 @@ object TryToTimestampExpressionBuilder extends 
ExpressionBuilder {
   override def build(funcName: String, expressions: Seq[Expression]): 
Expression = {
     val numArgs = expressions.length
     if (numArgs == 1 || numArgs == 2) {
-      ParseToTimestamp(
+      // The expression ParseToTimestamp will throw an SparkUpgradeException 
if the input is invalid
+      // even when failOnError is false. We need to catch the exception and 
return null.
+      TryEval(ParseToTimestamp(

Review Comment:
   so we need to maintain 3 behaviors:
   1. `try_to_timestamp` never fails
   2. `to_timestamp` ansi mode always fail with invalid input
   3. `to_timestamp` non-ansi mode only fails with `SparkUpgradeException`
   
   Do I understand it correctly?



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