-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Deprecate duplicate function LogicalPlan::with_new_inputs
#8707
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -541,35 +541,9 @@ impl LogicalPlan { | |
} | ||
|
||
/// Returns a copy of this `LogicalPlan` with the new inputs | ||
#[deprecated(since = "35.0.0", note = "please use `with_new_exprs` instead")] | ||
pub fn with_new_inputs(&self, inputs: &[LogicalPlan]) -> Result<LogicalPlan> { | ||
// with_new_inputs use original expression, | ||
// so we don't need to recompute Schema. | ||
match &self { | ||
LogicalPlan::Projection(projection) => { | ||
// Schema of the projection may change | ||
// when its input changes. Hence we should use | ||
// `try_new` method instead of `try_new_with_schema`. | ||
Projection::try_new(projection.expr.to_vec(), Arc::new(inputs[0].clone())) | ||
.map(LogicalPlan::Projection) | ||
} | ||
LogicalPlan::Window(Window { window_expr, .. }) => Ok(LogicalPlan::Window( | ||
Window::try_new(window_expr.to_vec(), Arc::new(inputs[0].clone()))?, | ||
)), | ||
LogicalPlan::Aggregate(Aggregate { | ||
group_expr, | ||
aggr_expr, | ||
.. | ||
}) => Aggregate::try_new( | ||
// Schema of the aggregate may change | ||
// when its input changes. Hence we should use | ||
// `try_new` method instead of `try_new_with_schema`. | ||
Arc::new(inputs[0].clone()), | ||
group_expr.to_vec(), | ||
aggr_expr.to_vec(), | ||
) | ||
.map(LogicalPlan::Aggregate), | ||
_ => self.with_new_exprs(self.expressions(), inputs), | ||
} | ||
self.with_new_exprs(self.expressions(), inputs) | ||
} | ||
|
||
/// Returns a new `LogicalPlan` based on `self` with inputs and | ||
|
@@ -591,10 +565,6 @@ impl LogicalPlan { | |
/// // create new plan using rewritten_exprs in same position | ||
/// let new_plan = plan.new_with_exprs(rewritten_exprs, new_inputs); | ||
/// ``` | ||
/// | ||
/// Note: sometimes [`Self::with_new_exprs`] will use schema of | ||
/// original plan, it will not change the scheam. Such as | ||
/// `Projection/Aggregate/Window` | ||
Comment on lines
-595
to
-597
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment looks incorrect. For |
||
pub fn with_new_exprs( | ||
&self, | ||
mut expr: Vec<Expr>, | ||
|
@@ -706,17 +676,10 @@ impl LogicalPlan { | |
})) | ||
} | ||
}, | ||
LogicalPlan::Window(Window { | ||
window_expr, | ||
schema, | ||
.. | ||
}) => { | ||
LogicalPlan::Window(Window { window_expr, .. }) => { | ||
assert_eq!(window_expr.len(), expr.len()); | ||
Ok(LogicalPlan::Window(Window { | ||
input: Arc::new(inputs[0].clone()), | ||
window_expr: expr, | ||
schema: schema.clone(), | ||
})) | ||
Comment on lines
680
to
-719
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a potential bug. Since input/window_expr will change, we shouldn't reuse previous schema. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe @mustafasrepo remembers the context -- I vaguely remember something like this but can't remember the specifics There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree that, previous version wasn't robust to expression and input changes. This version is much better. Thanks @viirya for catching this. |
||
Window::try_new(expr, Arc::new(inputs[0].clone())) | ||
.map(LogicalPlan::Window) | ||
} | ||
LogicalPlan::Aggregate(Aggregate { group_expr, .. }) => { | ||
// group exprs are the first expressions | ||
|
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.
I suggest we mark this deprecated for at least a release or two to help users migrate? I always apprecate the hint in the deprecation message that tells me what to change so I don't have to go poking around in the commit log to see what happened.
Perhaps it could call through to the
with_new_exprs
API, something like (untested):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.
Agreed. Marked it as deprecated one.