maropu commented on a change in pull request #28106: [SPARK-31335][SQL] Add try 
function support
URL: https://github.com/apache/spark/pull/28106#discussion_r407872797
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
 ##########
 @@ -198,3 +201,85 @@ case class TypeOf(child: Expression) extends 
UnaryExpression {
     defineCodeGen(ctx, ev, _ => 
s"""UTF8String.fromString(${child.dataType.catalogString})""")
   }
 }
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = """
+    _FUNC_(expr) - Evaluate an expression and handle certain types of runtime 
exceptions by returning NULL.
+    In cases where it is preferable that queries produce NULL instead of 
failing when corrupt or invalid data is encountered, the TRY function may be 
useful, especially when ANSI mode is on and the users need null-tolerant on 
certain columns or outputs.
+    AnalysisExceptions will not be handled by this, typically runtime 
exceptions handled by TRY function are:
+
+      * ArightmeticException - e.g. division by zero, numeric value out of 
range,
+      * NumberFormatException - e.g. invalid casting,
+      * IllegalArgumentException - e.g. invalid datetime pattern, missing 
format argument for string formatting,
+      * DateTimeException - e.g. invalid datetime values
+      * UnsupportedEncodingException - e.g. encode or decode string with 
invalid charset
 
 Review comment:
   Thanks for the update.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to