cloud-fan commented on code in PR #37483:
URL: https://github.com/apache/spark/pull/37483#discussion_r959122998
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala:
##########
@@ -1120,28 +1120,58 @@ case class Hex(child: Expression)
""",
since = "1.5.0",
group = "math_funcs")
-case class Unhex(child: Expression)
+case class Unhex(child: Expression, failOnError: Boolean = false)
extends UnaryExpression with ImplicitCastInputTypes with NullIntolerant {
+ def this(expr: Expression) = this(expr, false)
+
override def inputTypes: Seq[AbstractDataType] = Seq(StringType)
override def nullable: Boolean = true
override def dataType: DataType = BinaryType
- protected override def nullSafeEval(num: Any): Any =
- Hex.unhex(num.asInstanceOf[UTF8String].getBytes)
+ protected override def nullSafeEval(num: Any): Any = {
+ val result = Hex.unhex(num.asInstanceOf[UTF8String].getBytes)
+ if (failOnError && result == null) {
+ // The failOnError is set only from `ToBinary` function - hence we might
safely set `hint`
+ // parameter to `try_to_binary`.
Review Comment:
why not set the hint parameter to `to_binary`?
--
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]