andygrove commented on code in PR #2287:
URL: https://github.com/apache/datafusion-comet/pull/2287#discussion_r2319102119
##########
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)
Review Comment:
Let's remove the use of `unhexSerde` and the use of the tuple to make the
code easier to read:
```suggestion
val childExpr = exprToProtoInternal(expr.child, inputs, binding)
val failOnErrorExpr = exprToProtoInternal(Literal(expr.failOnError),
inputs, binding)
val optExpr =
scalarFunctionExprToProtoWithReturnType("unhex", expr.dataType,
childExpr, failOnErrorExpr)
optExprWithInfo(optExpr, expr, expr.child)
```
--
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]