Skip to content

fix: reject groups accumulator for bit_xor(DISTINCT) - #24989

Merged
jayzhan211 merged 3 commits into
apache:mainfrom
jackylee-ch:fix-distinct-bitwise-groups-accumulator
Sep 13, 2026
Merged

jayzhan211 merged 3 commits into
apache:mainfrom
jackylee-ch:fix-distinct-bitwise-groups-accumulator

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A

Rationale for this change

bit_xor(DISTINCT c) with GROUP BY fails with column types must match schema types, expected List(Int16) but found Int16: groups_accumulator_supported ignored is_distinct, so the plan got the non-distinct groups accumulator while state_fields declared the List state.

What changes are included in this PR?

groups_accumulator_supported now returns false only for bit_xor(DISTINCT), matching accumulator and state_fields. bit_and and bit_or are idempotent, so they keep the vectorized path.

What is the testing strategy for this PR?

Three aggregate.slt queries: the two shapes SingleDistinctToGroupBy does not rewrite (a non-distinct aggregate alongside, a FILTER) fail on main; a bit_and/bit_or DISTINCT row pins the narrower predicate.

Are there any user-facing changes?

bit_xor(DISTINCT) with GROUP BY now works. No API change.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Sep 6, 2026
@codecov-commenter

codecov-commenter commented Sep 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.88%. Comparing base (9082d6b) to head (92ce829).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24989      +/-   ##
==========================================
- Coverage   81.88%   81.88%   -0.01%     
==========================================
  Files        1133     1133              
  Lines      424522   424522              
  Branches   424522   424522              
==========================================
- Hits       347623   347611      -12     
- Misses      56285    56296      +11     
- Partials    20614    20615       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

jayzhan211
jayzhan211 previously approved these changes Sep 7, 2026

@jayzhan211 jayzhan211 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jackylee-ch 👍🏻

@jayzhan211
jayzhan211 dismissed their stale review September 7, 2026 12:50

Wait, I found an issue

fn groups_accumulator_supported(&self, _args: AccumulatorArgs) -> bool {
true
fn groups_accumulator_supported(&self, args: AccumulatorArgs) -> bool {
!args.is_distinct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we limit operator to XOR only, since AND and OR are idempotent so DISTINCT does not change their result and they keep the vectorized path.

Also, do we need to handle null case? This could be a follow-up issue

Suggested change
!args.is_distinct
!(args.is_distinct && self.operation == BitwiseOperationType::Xor)

AND and OR are idempotent, so DISTINCT does not change their result and
they keep the vectorized path.
@jackylee-ch jackylee-ch changed the title fix: reject groups accumulator for distinct bitwise aggregates fix: reject groups accumulator for bit_xor(DISTINCT) Sep 8, 2026

@jayzhan211 jayzhan211 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jackylee-ch 👍🏻

@jayzhan211
jayzhan211 added this pull request to the merge queue Sep 13, 2026
Merged via the queue into apache:main with commit 681705e Sep 13, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt) v56.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants