FIX - keep aux_table column order for default cols in AggJoiner and MultiAggJoiner - #2250
Merged
rcap107 merged 1 commit intoAug 24, 2026
Merged
Conversation
rcap107
approved these changes
Aug 24, 2026
Member
There was a problem hiding this comment.
Looks good to me, thanks a lot @dylanpulver ! Simple and useful fix
…ultiAggJoiner When `cols` is not provided, the columns to aggregate were collected with a set difference, so their order varied between interpreter runs and the aggregated output columns came out in a different order each time. Use the `(~s.cols(*key)).expand(table)` selector idiom that `aggregate()` uses in the same module, which walks `sbd.column_names` and therefore keeps the auxiliary table's own column order.
dylanpulver
force-pushed
the
fix-aggjoiner-default-cols-order
branch
from
August 24, 2026 18:45
a93eab8 to
527d7ba
Compare
rcap107
pushed a commit
to rcap107/skrub
that referenced
this pull request
Aug 27, 2026
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.
Bug Fix Pull Request
Description
AggJoinerandMultiAggJoinerderive their defaultcolsfrom a set difference, so the aggregated columns come out in a different order on each interpreter run. No existing issue; repro onmainat 9fb3ac5:The constraint on the replacement is that the default path has to agree with the explicit one. When
colsis passed,_colsis the caller's list in the caller's order, so aux table order is the only choice that makescols=Noneequivalent to passing every non-key column by hand.That is why
sorted()was rejected. It is deterministic, but it would give the default path an alphabetical order the explicit path never produces, and the two forms of the same request would disagree.(~s.cols(*key)).expand(table)is the selector expressionaggregate()uses in_agg_joiner.pyfor this same "everything but the key" selection.Selector.expanditeratessbd.column_names, which pins the result to the table's own order.Behavior change worth naming: for
cols=Nonethe output column order moves for any run that happened to land on a different permutation. Per-column values are unchanged, and no order was reproducible before, so nothing could have depended on a particular one.Residual:
aggregate()also buildsnum_only_opfrom a set intersection, so the operations listed in thatAttributeErrorare unordered too. That is message text rather than output, and it is untouched here.Checklist
How Has This Been Tested?
Full suite on this branch against a clean checkout of
mainat 9fb3ac5: 3029 passed vs 3026, with the same single pre-existing failure in both (skrub/datasets/tests/test_fetching.py::test_warning_redownload_checksum_has_changed, which downloads).Reverting the two source hunks while keeping the tests: the new
test_agg_joiner_default_cols_orderfails on everyPYTHONHASHSEEDfrom 0 to 11, across all threedf_modulevariants. The two pre-existing assertions that calledsorted()were tightened to exact order; those are weaker detectors, catching the old behavior on 10 of 30 and 9 of 12 seeds respectively, because permutations of two or three columns often coincide with table order by chance.ruff 0.14.4, the version pinned in
.pre-commit-config.yaml, reports no check or format changes.AI Disclosure