Repository navigation
GH-55575: [C++][Substrait] Fix inverted ddof for POPULATION/SAMPLE in DecodeBasicAggregate - #55582
Open
Mola-maker wants to merge 2 commits into
Open
Mola-maker wants to merge 2 commits into
Mola-maker wants to merge 2 commits into
Conversation
…PLE in DecodeBasicAggregate DecodeBasicAggregate mapped POPULATION to ddof=1 and SAMPLE to ddof=0, which is backwards: VarianceOptions uses N - ddof as the divisor, so population variance needs ddof=0 and sample variance needs ddof=1. The swap made a POPULATION request silently compute sample variance (and return NULL on a 1-row group), and vice versa. Fix the mapping and correct the AggregateRelOptions test, which encoded the buggy behavior, and add coverage for the SAMPLE distribution and for a single-row group (0.0 for POPULATION, NULL for SAMPLE). stddev shares this code path, so it is fixed by the same change.
|
|
Collaborator
|
@Mola-maker Pls use ARROW PR template. |
Author
|
ok,I'll rewrite the pr tomorrow.Thanks! |
|
|
Author
|
@Reranko05 I've updated my PR &ready for review.Thanks! |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
DecodeBasicAggregateinverted thevarianceandstd_devdistribution options for Substrait:POPULATIONwas mapped toddof = 1andSAMPLEtoddof = 0, causing calculation errors (such as returningNULLfor single rows) due to the reversedN - ddofdivisor.What changes are included in this PR?
ddofmapping inDecodeBasicAggregate:POPULATIONset toddof = 0,SAMPLEset toddof = 1.SubstraitRoundTrip.AggregateRelOptionstest case.AggregateRelOptionsSample,AggregateRelVarianceSingleRowGroup, andAggregateRelVarianceSingleRowGroupSamplefor edge cases.Are these changes tested?
Yes. Updated round-trip tests and added new unit tests and all 113 fork CI tasks (ASAN/UBSAN and ARM64) passed.
Are there any user-facing changes?
Yes. Fixed a bug where
POPULATIONandSAMPLEoptions were inverted when executingvarianceorstd_devin Substrait plans.Was AI used for this PR?
AI tools helped furnishing my code.
PR code and description written by:
Reviewed before submission by: