Skip to content

Fix stacking bug#403

Open
teunbrand wants to merge 1 commit intoposit-dev:mainfrom
teunbrand:fix-stack-sort-order
Open

Fix stacking bug#403
teunbrand wants to merge 1 commit intoposit-dev:mainfrom
teunbrand:fix-stack-sort-order

Conversation

@teunbrand
Copy link
Copy Markdown
Collaborator

This PR aims to fix #402.

Briefly, the partition_by is a HashMap, which has non-deterministic order. This made facets land in the wrong place in the sorting hierarchy, which led to treating every row as its own group. The fix is to put facet columns as the outer sorting columns.

The sort in apply_stack used [group_col, ...partition_by] as sort keys,
but partition_by order is non-deterministic (HashMap iteration). When
fill sorted before facet, rows from the same facet panel were
interleaved, causing compute_group_ids (which relies on adjacency) to
treat every row as its own group — making cumsum a no-op.

Fix: build the over/group columns first, use them as primary sort keys,
then append remaining partition_by columns after.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@teunbrand teunbrand marked this pull request as ready for review April 29, 2026 14:57
@teunbrand teunbrand requested a review from thomasp85 April 29, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stacking bug

1 participant