sql: Refactor MapFilterProject, MfpPlan, and SafeMfpPlan to have parameter with trait#36759
Conversation
|
Triggered the random query subset of Nightly: https://buildkite.com/materialize/nightly/builds/16607 |
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| { |
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.)
There was a problem hiding this comment.
There are a bunch of deprecated things here... is there any reason not to move everything to iterative work?
There was a problem hiding this comment.
#36852 takes a cut at iterative visitors. This took me longer than I expected, mostly because post-order mutable traversal requires unsafe rust.
In the meantime, I made it so we can override visit_pre. It should go away once we have the iterative refactor, though.
…t to indicate necessary interface
88e78df to
14f9369
Compare
|
I'm not sure this is important enough to be considered a bug, but it's definitely a regression, the query worked fine before, now errors: with this .td file: |
|
Thanks, @def- ! We'll fix this as a followup, as part of some more visitor changes. |
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.