You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some aggregates silently ignore IGNORE NULLS and ORDER BY on arguments #9924
changed the title [-]Aggregates ignore `IGNORE NULLS` and `ORDER BY` on arguments[/-][+]Some aggregates silently ignore `IGNORE NULLS` and `ORDER BY` on arguments[/+]on Apr 3, 2024
I think for AVG, or COUNT type of aggregates we can safely ignore ORDER BY expression. Since operation result is same for any permutation of the input. However, for first_value, nth_value, last_value this is not the case. However, I agree that IGNORE NULLS should raise an error.
I think for AVG, or COUNT type of aggregates we can safely ignore ORDER BY expression. Since operation result is same for any permutation of the input.
That is true, though applying an ORDER BY to the argument of COUNT may be much slower 🤔 (as DataFusion would have to sort the input)
However, we could remove ORDER BY that don't change the output as a follow on optimization
Specifically, add these two functions to the AggregateUDFImpl
/// Return true if the aggregate supports `IGNORE NULL`sfnsupport_ignore_nulls() -> bool{false}/// Return true if the aggregate supports and `ORDER BY` to specify its ordering:/// `SELECT first_value(x ORDER BY y) ... `fnsupport_ordering() -> bool{false}
Specifically, add these two functions to the AggregateUDFImpl
/// Return true if the aggregate supports `IGNORE NULL`sfnsupport_ignore_nulls() -> bool{false}/// Return true if the aggregate supports and `ORDER BY` to specify its ordering:/// `SELECT first_value(x ORDER BY y) ... `fnsupport_ordering() -> bool{false}
I think these APIs are very nice, clear. We can add these supports
Activity
[-]Aggregates ignore `IGNORE NULLS` and `ORDER BY` on arguments[/-][+]Some aggregates silently ignore `IGNORE NULLS` and `ORDER BY` on arguments[/+]comphead commentedon Apr 3, 2024
@huaxingao this might be interesting
huaxingao commentedon Apr 3, 2024
@comphead Thanks for pinging me! I will work on this issue.
mustafasrepo commentedon Apr 4, 2024
I think for
AVG, orCOUNTtype of aggregates we can safely ignoreORDER BYexpression. Since operation result is same for any permutation of the input. However, forfirst_value,nth_value,last_valuethis is not the case. However, I agree thatIGNORE NULLSshould raise an error.alamb commentedon Apr 4, 2024
That is true, though applying an ORDER BY to the argument of COUNT may be much slower 🤔 (as DataFusion would have to sort the input)
However, we could remove
ORDER BYthat don't change the output as a follow on optimizationalamb commentedon Apr 4, 2024
FWIW @jayzhan211 has a really nice API suggestion here I think https://github.com/apache/arrow-datafusion/pull/9920/files#r1549905825
Specifically, add these two functions to the
AggregateUDFImplalamb commentedon Apr 4, 2024
I wrote some tests for this feature in another PR that we decided not to use. I put them here #9953 in case that is helpful @huaxingao
mustafasrepo commentedon Apr 5, 2024
I think these APIs are very nice, clear. We can add these supports
vbarua commentedon Mar 4, 2025
I opened up an issue that's potentially related to this when it comes to supporting IGNORE NULLS
#15006
Change default of `AggregateUDFImpl::supports_null_handling_clause` t…