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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -106,6 +106,37 @@ case class UrlDecode(child: Expression)
   override def prettyName: String = "url_decode"
 }
 
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = """
+    _FUNC_(str) - This is a special version of `url_decode` that performs the 
same operation, but returns a NULL value instead of raising an error if the 
decoding cannot be performed.
+  """,
+  arguments = """
+    Arguments:
+      * str - a string expression to decode
+  """,
+  examples = """
+    Examples:
+      > SELECT _FUNC_('https%3A%2F%2Fspark.apache.org');
+       https://spark.apache.org
+  """,
+  since = "4.0.0",
+  group = "url_funcs")
+// scalastyle:on line.size.limit
+case class TryUrlDecode(expr: Expression, replacement: Expression)
+  extends RuntimeReplaceable with InheritAnalysisRules {
+
+  def this(expr: Expression) = this(expr, TryEval(UrlDecode(expr)))

Review Comment:
   I'm not a big fan of `TryEval` as it catches all the exceptions, including 
the ones not from `UrlDecode`, but from its input expressions.
   
   We should add a boolean flag in `UrlDecode` to control the null-on-error 
behavior.



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