-
Notifications
You must be signed in to change notification settings - Fork 466
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
transform: Turn a Join with a constant input into a FlatMap or Map #29683
base: main
Are you sure you want to change the base?
Conversation
d1d1e4c
to
47c3fbb
Compare
47c3fbb
to
905792b
Compare
.unwrap() | ||
.filter(unpack_equivalences(equivalences)); | ||
return Ok(false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was factored out into the eliminate_trivial_join
call above.
Bringing back to draft, because Nightly is showing a possible bug. Edit: No, see below. |
Nightly https://buildkite.com/materialize/nightly/builds/9664:
Ready for review! |
@frankmcsherry, may I ask you to review this one? I think you mentioned this optimization several times in the past. |
This finally implements the transform that turns Joins that have constant inputs into a
FlatMap
orMap
. This would have been useful many times in the past few years, see links in the issue (#20637). (Most recently, there were some confusions at https://github.com/MaterializeInc/accounts/issues/3 around the manual broadcast join pattern.) Importantly, this turns a non-scalable computation (cross-join) into a scalable one (FlatMap
orMap
).Notably, I've put this near the beginning of the MIR optimization pipeline, before join fusion, explained in the doc comment of
join_to_flat_map.rs
.It's guarded by a feature flag, but I've enabled it by default. I think there is a relatively low risk of significant regressions.
cc @sthm
Motivation
FlatMap
#20637Tips for reviewer
The first commit just adds the feature flag, which is a bit noisy, so I recommend reviewing this commit separately.
Checklist
join-lateral.slt:133
tests the situation when the join has equivalences.)$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.