Skip to content

Ensure DISTINCT aggregates share branch only with matching ORDER BY - #27852

Merged
lnkuiper merged 1 commit into
duckdb:mainfrom
KassaSana:fix-27815-distinct-order-sets
Nov 2, 2026
Merged

lnkuiper merged 1 commit into
duckdb:mainfrom
KassaSana:fix-27815-distinct-order-sets

Conversation

@KassaSana

Copy link
Copy Markdown
Contributor

Non-argument ORDER BY expressions become deduplication keys of the shared distinct branch, so merging an ordered DISTINCT aggregate into a set changed which rows the other members treated as duplicates. Two aggregates now only share a DistinctAggregateSet when their non-argument ORDER BY expressions match.

Fixes #27815

Non-argument ORDER BY expressions become deduplication keys of the shared
distinct branch, so merging an ordered DISTINCT aggregate into a set changed
which rows the other members treated as duplicates. Two aggregates now only
share a DistinctAggregateSet when their non-argument ORDER BY expressions
match.

Fixes duckdb#27815
Copilot AI balanced review requested due to automatic review settings October 25, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@duckdb-draftbot
duckdb-draftbot marked this pull request as draft October 25, 2026 16:43
@KassaSana
KassaSana marked this pull request as ready for review October 27, 2026 21:27
@lnkuiper
lnkuiper enabled auto-merge November 2, 2026 14:21
@lnkuiper
lnkuiper added this pull request to the merge queue Nov 2, 2026
Merged via the queue into duckdb:main with commit 2ad015d Nov 2, 2026
98 of 115 checks passed
PeterVanHolland pushed a commit to PeterVanHolland/duckdb that referenced this pull request Nov 4, 2026
…uckdb#27852)

Non-argument ORDER BY expressions become deduplication keys of the
shared distinct branch, so merging an ordered DISTINCT aggregate into a
set changed which rows the other members treated as duplicates. Two
aggregates now only share a DistinctAggregateSet when their non-argument
ORDER BY expressions match.

Fixes duckdb#27815

Co-authored-by: KassaSana03 <[email protected]>
PeterVanHolland pushed a commit to PeterVanHolland/duckdb that referenced this pull request Nov 4, 2026
## Summary

Backports the PRs labeled `backport v2.0-cyanoptera` that are merged
into `main` and not yet on this branch (oldest-first), as one squash
commit per PR with the original author (`Co-authored-by` for further
authors):

duckdb#27958, duckdb#27869, duckdb#28043, duckdb#28065, duckdb#28066, duckdb#27690, duckdb#28046, duckdb#28042, duckdb#28074,
duckdb#28056, duckdb#28037, duckdb#28073, duckdb#28005, duckdb#28016, duckdb#28076, duckdb#28104, duckdb#28108, duckdb#28087,
duckdb#28097, duckdb#27767, duckdb#27998, duckdb#28029, duckdb#28121, duckdb#28119, duckdb#28120, duckdb#28109, duckdb#28117,
duckdb#27916, duckdb#28118, duckdb#27860, duckdb#28114, duckdb#27923, duckdb#27804, duckdb#28098, duckdb#27915, duckdb#27930,
duckdb#28213, duckdb#28217, duckdb#28210, duckdb#28134, duckdb#28222, duckdb#28231, duckdb#28232, duckdb#28235, duckdb#28239,
duckdb#28241, duckdb#28019, duckdb#28199, duckdb#28230, duckdb#28188, duckdb#28246, duckdb#28245, duckdb#28228, duckdb#28251,
duckdb#27852, duckdb#28223, duckdb#28252, duckdb#28258, duckdb#28253, duckdb#28180, duckdb#27779.

## Not included

These depend on changes that are not on this branch:

- duckdb#27943: needs 321ded7 (constant and dictionary vectors in
`ColumnDataCollection`).
- duckdb#27999: needs index-key collation, TRY-subquery binder state and
update-segment changes.
- duckdb#27326: needs 32cb90d (Parquet Thrift metadata arena).
- duckdb#28225: needs the TRY lowering (`ExpressionType::OPERATOR_HAS_ERROR`).
- duckdb#27849: the regenerated parser trampolines did not build on this
branch.

## Notes

- duckdb#28119 and duckdb#28120 report the same merge commit in the GitHub API,
duckdb#28120 is picked from its own commit.
- Dropped test hunks and files that belong to features not on this
branch (duckdb#28029, duckdb#27998, duckdb#28076, duckdb#28188, duckdb#28056, duckdb#27767, duckdb#27804).
- Built `reldebug` and ran all added or changed `.test` files: all pass.
The full suite was not run.

- Release-only change, not a backport: `round` in
`extension/core_functions/scalar/math/numeric.cpp` now rounds half away
from zero without calling the platform `round` (MinGW rounds
`0.49999999999999994` to `1`). `main` still uses `std::round`; the same
fix is open in duckdb#28306 and duckdb#28307, so it should be backported once one of
them merges.
- Release-only change, not a backport: the 256 MB and 512 MB `SELECT 42`
cases in `tools/shell/tests/test_address_space_limit.py` are skipped
because they segfault on v2.0-cyanoptera after running out of address
space at startup. Whether the fix in duckdb#28310 can be backported to
re-enable them is still to be checked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants