GaneshPatil7517 opened a new pull request, #19618: URL: https://github.com/apache/datafusion/pull/19618
Closes #19612 Rationale for this change When aggregate functions are used with window frames like ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, DataFusion uses PlainAggregateWindowExpr which calls [evaluate()](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) multiple times on the same accumulator instance. Accumulators that use [std::mem::take()](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) in their [evaluate()](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) method consume their internal state, causing incorrect results on subsequent calls. What changes are included in this PR? percentile_cont: Modified [evaluate()](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) to use mutable reference instead of consuming the Vec. Added retract_batch() support. string_agg: Changed [SimpleStringAggAccumulator::evaluate()](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) to clone instead of take. Added comprehensive test cases in [aggregate.slt](vscode-file://vscode-app/c:/Users/HP/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) Added documentation about window-compatible accumulators Are these changes tested? Yes, added sqllogictest cases that verify: median() and percentile_cont(0.5) produce identical results in window frames percentile_cont with different percentiles works correctly string_agg accumulates correctly across window frame evaluations Are there any user-facing changes? No breaking changes. This is a bug fix that ensures aggregate functions work correctly in window contexts. -- 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]
