sql: Refactor MapFilterProject, MfpPlan, and SafeMfpPlan to have parameter with trait#36759
Open
mgree wants to merge 1 commit into
Open
sql: Refactor MapFilterProject, MfpPlan, and SafeMfpPlan to have parameter with trait#36759mgree wants to merge 1 commit into
mgree wants to merge 1 commit into
Conversation
…t to indicate necessary interface
Contributor
|
Triggered the random query subset of Nightly: https://buildkite.com/materialize/nightly/builds/16607 |
ggevay
approved these changes
May 28, 2026
Contributor
ggevay
left a comment
There was a problem hiding this comment.
LGTM, if Nightly is green
| expr.visit_pre(|e| { | ||
| if let MirScalarExpr::Column(i, _name) = e { | ||
| reference_count[*i] += 1; | ||
| expr.visit_pre(&mut |e| { |
Contributor
There was a problem hiding this comment.
Minor thing: originally, this was MSE's visit_pre, which is written iteratively (the worklist stuff) to avoid recursion limit issues, while the new code is calling the Visit trait's visit_pre, which is Stacker-based. So, we now could newly panic on a recursion limit error. I'm wondering if the Visit trait's implementation could also be changed to be iterative.
(And the same at the below visit_pre call.)
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.
Motivation
Second PR pulled from #36544.
Description
MapFilterProject(and its friends,MfpPlanandSafeMfpPlan---the "MFP" family) are used at both the MIR and LIR level. To separate LIR cleanly from MIR, we need to be able to work with MFPs at both levels.This change parameterizes these types and introduces a trait
OptimizableExprthat allows us to work independently of the MIR type. It is not the prettiest trait, but I don't see how to work around this (without a much more intensive overhaul of how we process MFP-like structures in LIR). See also: https://linear.app/materializeinc/issue/SQL-319/mfp-like-structures-in-lir-are-optimized-late.Verification
Pure refactor, CI green.