datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

`var(distinct)` support

Open WinkerDu opened this issue 3 years ago • 1 comments

Is your feature request related to a problem or challenge? Please describe what you are trying to do. complete description later.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

WinkerDu avatar May 02 '22 11:05 WinkerDu

Checklist of things needed to be implemented. For reference existing implementation:

https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/functions-aggregate/src/variance.rs

Distinct accumulator for variance, see example for median:

https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/functions-aggregate/src/median.rs#L511-L542

Make sure to wire distinct accumulator into the UDAF:

https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/functions-aggregate/src/median.rs#L151-L184

https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/functions-aggregate/src/median.rs#L132-L149

Add tests here:

https://github.com/apache/datafusion/blob/2a08013af3ccf703bee202c959b40bb0d35bdea1/datafusion/sqllogictest/test_files/aggregate.slt

Jefffrey avatar Dec 10 '25 13:12 Jefffrey