kosiew commented on code in PR #27570:
URL: https://github.com/apache/datafusion/pull/27570#discussion_r4663909437
##########
datafusion/expr/src/logical_plan/materialized_cte.rs:
##########
@@ -151,6 +151,18 @@ impl MaterializedCte {
MaterializedCteScan::find_in(&self.continuation, self.id)
}
+ /// 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>) {
Review 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.
##########
docs/source/library-user-guide/upgrading/57.0.0.md:
##########
@@ -168,3 +168,10 @@ schema.
has the names and types of the columns that it reads from the body. The
optimizer runs this check after each rule in debug builds, so a custom rule
that does not remap the scans now fails with an error that names the rule.
+
+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
Review 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.
##########
datafusion/expr/src/logical_plan/materialized_cte.rs:
##########
@@ -151,6 +151,18 @@ impl MaterializedCte {
MaterializedCteScan::find_in(&self.continuation, self.id)
}
+ /// 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>) {
+ (&mut self.cte, &mut self.continuation)
+ }
+
+ /// 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>) {
Review 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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]