wForget commented on code in PR #47294:
URL: https://github.com/apache/spark/pull/47294#discussion_r1682257760
##########
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:
> or do some major refactor so that it will not swallow the errors from its
child's children expressions.
I have an idea for this, we can add a `TryCheck` expression which will wrap
the exception of child expression and throw it, `TryEval` will throw the caught
exception wrapped by `TryCheck`.
For current case, the `try_url_decode` replacement expression changes to
`TryEval(UrlDecode(TryCheck(expr)))`, `TryEval` will only work on the exception
raised by `UrlDecode`.
@cloud-fan Is this feasible?
--
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]