jayzhan211 commented on code in PR #10214:
URL: https://github.com/apache/datafusion/pull/10214#discussion_r1579357369
##########
datafusion/expr/src/udaf.rs:
##########
@@ -354,6 +360,24 @@ pub trait AggregateUDFImpl: Debug + Send + Sync {
fn aliases(&self) -> &[String] {
&[]
}
+
+ /// Construct an expression that calculates the aggregate in reverse.
+ /// Typically the "reverse" expression is itself (e.g. SUM, COUNT).
+ /// For aggregates that do not support calculation in reverse,
+ /// returns None (which is the default value).
+ fn reverse_expr(&self) -> ReversedExpr {
+ ReversedExpr::NotSupported
+ }
+}
+
+#[derive(Debug)]
+pub enum ReversedExpr {
+ /// The expression is the same as the original expression, like SUM, COUNT
+ Identical,
+ /// The expression does not support reverse calculation, like ArrayAgg
+ NotSupported,
Review Comment:
Yes, because ArrayAgg has no ordering info.
You can also take a look at this comment
https://github.com/apache/datafusion/issues/9972#issuecomment-2055582944
Although I found that the counter-example might not be correct after a few
days, `ARRAY_AGG(b ORDER BY c DESC)` is OrderSensitiveArrayAgg, so it is
possible to produce reverse expr, but it still makes sense to me that order
insensitive ArrayAgg (which is ArrayAgg) does not support `reverse_expr`. cc
@mustafasrepo
--
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]