andygrove commented on code in PR #1943:
URL: https://github.com/apache/datafusion-comet/pull/1943#discussion_r2173423255
##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -1179,6 +1179,29 @@ object QueryPlanSerde extends Logging with CometExprShim
{
})
optExprWithInfo(optExpr, expr, child)
+ case FromUnixTime(sec, format, timeZoneId) =>
+ val secExpr = exprToProtoInternal(sec, inputs, binding)
+ val formatExpr = exprToProtoInternal(format, inputs, binding)
+ val timeZone = exprToProtoInternal(Literal(timeZoneId.orNull), inputs,
binding)
+
+ // TODO: DataFusion toChar does not support Spark format
+ // https://github.com/apache/datafusion/issues/16577
+ // https://github.com/apache/datafusion/issues/14536
+ // TODO: DataFusion supports only -8334601211038 <= sec <=
8210266876799
+ // https://github.com/apache/datafusion/issues/16594
+ // if (secExpr.isDefined && formatExpr.isDefined) {
+ // val timestampExpr = scalarFunctionExprToProto("from_unixtime",
Seq(secExpr, timeZone): _*)
+ // val optExpr = scalarFunctionExprToProto("to_char",
Seq(timestampExpr, formatExpr): _*)
+ // optExprWithInfo(optExpr, expr, sec, format)
+ if (secExpr.isDefined && formatExpr.isDefined && format == Literal(
+ TimestampFormatter.defaultPattern)) {
+ val optExpr = scalarFunctionExprToProto("from_unixtime",
Seq(secExpr, timeZone): _*)
+ castToProto(expr, timeZoneId, StringType, optExpr.get,
CometEvalMode.LEGACY)
+ } else {
+ withInfo(expr, sec, format)
+ None
+ }
Review Comment:
nit: rather than adding this code directly in this file, could you delegate
to an object that implements `CometExpressionSerde`. See
https://github.com/apache/datafusion-comet/pull/1932 for an example of this
approach.
--
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]