coderfender commented on code in PR #3757:
URL: https://github.com/apache/datafusion-comet/pull/3757#discussion_r2970600883
##########
spark/src/main/scala/org/apache/comet/serde/aggregates.scala:
##########
@@ -671,6 +672,62 @@ object CometBloomFilterAggregate extends
CometAggregateExpressionSerde[BloomFilt
}
}
+object CometPercentile extends CometAggregateExpressionSerde[Percentile] {
+ override def convert(
+ aggExpr: AggregateExpression,
+ expr: Percentile,
+ inputs: Seq[Attribute],
+ binding: Boolean,
+ conf: SQLConf): Option[ExprOuterClass.AggExpr] = {
+
+ // Only support when frequency is Literal(1L) - i.e., percentile_cont
behavior
+ expr.frequencyExpression match {
+ case Literal(1L, LongType) =>
+ case _ =>
+ withInfo(aggExpr, "weighted percentile not supported")
+ return None
+ }
+
+ // Only support scalar percentile, not array of percentiles
+ if (expr.percentageExpression.dataType.isInstanceOf[ArrayType]) {
+ withInfo(aggExpr, "array of percentiles not supported")
+ return None
+ }
+
+ // Support numeric types and interval types
+ expr.child.dataType match {
+ case _: NumericType =>
+ case _: DecimalType =>
+ case _: YearMonthIntervalType =>
+ case _: DayTimeIntervalType =>
+ case _ =>
+ withInfo(aggExpr, s"unsupported input type: ${expr.child.dataType}")
+ return None
+ }
+
+ val childExpr = exprToProto(expr.child, inputs, binding)
+ val percentileExpr = exprToProto(expr.percentageExpression, inputs,
binding)
+ val dataType = serializeDataType(expr.dataType)
+
Review Comment:
nit : Any reason this if condition wouldn't always be true at all times ?
--
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]