Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLv2] Prescribe the order for metabase.lib.column-group/group-columns #38587

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

bshepherdson
Copy link
Contributor

@bshepherdson bshepherdson commented Feb 8, 2024

The desired order is: own columns, explicitly joined, implicitly joined.
Explicit joins are ordered among themselves by join alias. Implicit
joins are ordered by the join alias of the FK (own columns first), then
by the name of the FK column.

Previously this order has usually been at least close to the desired
order by accident, since it's close to the iteration order of
visible-columns. However, group-columns uses group-by, which
returns a map. If there are enough groups (more than 8 I think) the map
implementation will switch from a [key1 value1 key2 value2 ...] array
to a real map, and the iteration order is undefined.

This change enforces the desired order, including a test that shuffles
the columns. (And fixing the expectations for a few other tests.)

Fixes #38329.

Copy link
Contributor Author

bshepherdson commented Feb 8, 2024

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@metabase-bot metabase-bot bot added the .Team/QueryProcessor :hammer_and_wrench: label Feb 8, 2024
@bshepherdson bshepherdson added the no-backport Do not backport this PR to any branch label Feb 8, 2024
Copy link

replay-io bot commented Feb 8, 2024

Status In Progress ↗︎ 51 / 52
Commit 7690738
Results
⚠️ 3 Flaky
2312 Passed

Comment on lines +446 to +449
{::lib.column-group/group-type :group-type/join.implicit
:fk-join-alias "Orders"
:fk-field-id (meta/id :orders :product-id)}
Copy link
Contributor

Choose a reason for hiding this comment

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

You missed this entry in the comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it was included in one line, but that was left over from when the comment was phrased differently and grouped the joins rather than listing each one.

Fixed.

@bshepherdson bshepherdson force-pushed the mblib-column-group-ordering branch 2 times, most recently from ede1e69 to a480435 Compare February 12, 2024 14:01
@bshepherdson bshepherdson enabled auto-merge (squash) February 12, 2024 14:30
@bshepherdson bshepherdson added backport Automatically create PR on current release branch on merge and removed no-backport Do not backport this PR to any branch labels Feb 12, 2024
@bshepherdson
Copy link
Contributor Author

Adding backport now since 49 has been cut. This is a small fix to a pretty bad UX, so it should get into 49.

@bshepherdson bshepherdson force-pushed the mblib-column-group-ordering branch 3 times, most recently from 3fe32ac to ee08be3 Compare February 16, 2024 14:48
The desired order is: own columns, explicitly joined, implicitly joined.
Explicit joins are ordered among themselves by join alias. Implicit
joins are ordered by the join alias of the FK (own columns first), then
by the name of the FK column.

Previously this order has usually been at least close to the desired
order by accident, since it's close to the iteration order of
`visible-columns`. However, `group-columns` uses `group-by`, which
returns a map. If there are enough groups (more than 8 I think) the map
implementation will switch from a `[key1 value1 key2 value2 ...]` array
to a real map, and the iteration order is undefined.

This change enforces the desired order, including a test that `shuffle`s
the columns. (And fixing the expectations for a few other tests.)
@bshepherdson bshepherdson merged commit 8376ca8 into master Feb 21, 2024
107 checks passed
@bshepherdson bshepherdson deleted the mblib-column-group-ordering branch February 21, 2024 23:11
Copy link

@bshepherdson Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

github-actions bot pushed a commit that referenced this pull request Feb 21, 2024
…ns` (#38587)

The desired order is: own columns, explicitly joined, implicitly joined.
Explicit joins are ordered among themselves by join alias. Implicit
joins are ordered by the join alias of the FK (own columns first), then
by the name of the FK column.

Previously this order has usually been at least close to the desired
order by accident, since it's close to the iteration order of
`visible-columns`. However, `group-columns` uses `group-by`, which
returns a map. If there are enough groups (more than 8 I think) the map
implementation will switch from a `[key1 value1 key2 value2 ...]` array
to a real map, and the iteration order is undefined.

This change enforces the desired order, including a test that `shuffle`s
the columns. (And fixing the expectations for a few other tests.)
metabase-bot bot added a commit that referenced this pull request Feb 21, 2024
…ns` (#38587) (#39036)

The desired order is: own columns, explicitly joined, implicitly joined.
Explicit joins are ordered among themselves by join alias. Implicit
joins are ordered by the join alias of the FK (own columns first), then
by the name of the FK column.

Previously this order has usually been at least close to the desired
order by accident, since it's close to the iteration order of
`visible-columns`. However, `group-columns` uses `group-by`, which
returns a map. If there are enough groups (more than 8 I think) the map
implementation will switch from a `[key1 value1 key2 value2 ...]` array
to a real map, and the iteration order is undefined.

This change enforces the desired order, including a test that `shuffle`s
the columns. (And fixing the expectations for a few other tests.)

Co-authored-by: Braden Shepherdson <braden@metabase.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Automatically create PR on current release branch on merge .Team/QueryProcessor :hammer_and_wrench:
Projects
None yet
2 participants