andygrove commented on code in PR #2287:
URL: https://github.com/apache/datafusion-comet/pull/2287#discussion_r2319087877
##########
spark/src/main/scala/org/apache/comet/serde/math.scala:
##########
@@ -112,6 +112,40 @@ object CometLog2 extends CometExpressionSerde[Log2] with
MathExprBase {
}
}
+object CometHex extends CometExpressionSerde[Hex] with MathExprBase {
+ override def convert(
+ expr: Hex,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+ val optExpr = scalarFunctionExprToProtoWithReturnType("hex",
expr.dataType, childExpr)
+ optExprWithInfo(optExpr, expr, expr.child)
+ }
+}
+
+object CometUnhex extends CometExpressionSerde[Unhex] with MathExprBase {
+ override def convert(
+ expr: Unhex,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[ExprOuterClass.Expr] = {
+ val unHex = unhexSerde(expr)
+
+ val childExpr = exprToProtoInternal(unHex._1, inputs, binding)
+ val failOnErrorExpr = exprToProtoInternal(unHex._2, inputs, binding)
+
+ val optExpr =
+ scalarFunctionExprToProtoWithReturnType("unhex", expr.dataType,
childExpr, failOnErrorExpr)
+ optExprWithInfo(optExpr, expr, unHex._1)
+ }
+
+ /**
+ * Returns a tuple of expressions for the `unhex` function.
+ */
+ private def unhexSerde(unhex: Unhex): (Expression, Expression) = {
+ (unhex.child, Literal(unhex.failOnError))
Review Comment:
Agreed
--
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]