mkleen opened a new pull request, #27880: URL: https://github.com/apache/datafusion/pull/27880
## Which issue does this PR close? - Part of #26138. ## Rationale for this change A `GROUP BY` over input sorted on a float key can return the same group twice: ```sql SET datafusion.execution.target_partitions = 1; SET datafusion.execution.batch_size = 3; CREATE TABLE t(a DOUBLE, g INT) AS VALUES (-0.0, 1), (-0.0, 2), (0.0, 2), (0.0, 1); SELECT a, g, count(*) FROM (SELECT * FROM t ORDER BY a LIMIT 10) s GROUP BY a, g; -- 0 1 2 -- 0 2 1 -- 0 2 1 ``` The aggregate emits a group once its run of sorted keys ends. Inside a batch it finds runs on the raw keys, so a run ends between `-0.0` and `0.0`, even though they are the same group. Between batches it already compares them as equal. ## What changes are included in this PR? Find runs on keys passed through `float_semantics::normalize`, the same way grouping does. A one-line change. Input sorted on all group keys (`ORDER BY a, g`) has the same symptom, but there the sort order itself is wrong. That is part of the fix for #26115. A follow-up could normalize once in `evaluate_group_by` instead, so every consumer of the group keys gets them normalized. ## What is the testing strategy for this PR? The repro above in `negative_zero.slt`. It fails on `main`. ## Are there any user-facing changes? No. -- 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]
