Repository navigation
Conversation
adriangb
force-pushed
the
mcte-private-fields
branch
from
November 19, 2026 17:17
5b625f0 to
bdf3a4d
Compare
A rule that builds a MaterializedCte with a struct literal or struct update skips the scan check in try_new. Private fields send every new node through try_new, and every in-place change through inputs_mut or with_new_inputs. The fields are pub(crate), so the tree-node and display code of datafusion-expr is unchanged. inputs_mut and into_inputs replace the remaining direct field access in the optimizer and the physical planner.
adriangb
force-pushed
the
mcte-private-fields
branch
from
November 20, 2026 06:15
bdf3a4d to
ffb77b4
Compare
adriangb
marked this pull request as ready for review
November 20, 2026 06:24
Contributor
Author
kosiew
reviewed
Nov 23, 2026
|
|
||
| /// The body and the continuation, in this order, for a rule that changes | ||
| /// them in place. The schemas of the scans are not checked again. | ||
| pub fn inputs_mut(&mut self) -> (&mut Arc<LogicalPlan>, &mut Arc<LogicalPlan>) { |
Contributor
There was a problem hiding this comment.
Could we replace inputs_mut with a fallible closure-based try_map_inputs_mut and make with_new_inputs return Result<Self>? Both can remain unchecked for now, but these signatures would permit future validation.
| The fields of `MaterializedCte` are private. Read them with | ||
| `MaterializedCte::id`, `name`, `body` and `continuation`. Build a node with | ||
| `MaterializedCte::try_new`, which checks the scans of the CTE. A rule that | ||
| changes the inputs in place can use `MaterializedCte::inputs_mut` or |
Contributor
There was a problem hiding this comment.
Nit: with_new_inputs returns a new node rather than modifying inputs in place. Please distinguish it from the in-place mutation API and document which paths validate scans.
|
|
||
| /// The body and the continuation, in this order. Build a node again with | ||
| /// [`Self::try_new`]. | ||
| pub fn into_inputs(self) -> (Arc<LogicalPlan>, Arc<LogicalPlan>) { |
Contributor
There was a problem hiding this comment.
Optional: could into_parts return the ID, name, body, and continuation? Current callers copy the name before consuming the node. Moving all four values would simplify reconstruction.
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.
Which issue does this PR close?
Follow-up to #26274. This PR is stacked on it: only the last commit belongs to this PR. Review #26274 first.
Rationale for this change
#26274 makes the
schemaandprojectionfields ofMaterializedCteScanprivate, so that they always match. TheMaterializedCtenode still has public fields. A rule that builds the node with a struct literal or a struct update skips the scan check inMaterializedCte::try_new.What changes are included in this PR?
MaterializedCtearepub(crate). Downstream code reads them throughid(),name(),body()andcontinuation().MaterializedCte::inputs_mutandMaterializedCte::into_inputsreplace the direct field access in the optimizer driver,TypeCoercion,DecorrelatePredicateSubquery,PushDownFilter,OptimizeProjectionsand the physical planner.try_new, so the scans are checked.Are these changes tested?
Yes, by the existing tests. The change does not change behavior.
Are there any user-facing changes?
Yes. This is a breaking API change, which the 57.0.0 upgrade guide describes.