-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Minor: Make ProjectionExpr::new easier to use with constants
#19343
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
Conversation
| impl ProjectionExpr { | ||
| /// Create a new projection expression | ||
| pub fn new(expr: Arc<dyn PhysicalExpr>, alias: String) -> Self { | ||
| pub fn new(expr: Arc<dyn PhysicalExpr>, alias: impl Into<String>) -> Self { |
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.
this is the actual code change, the rest of the PR is cleaning up callsites
| let proj_expr = vec![ProjectionExpr::new( | ||
| Arc::new(Column::new_with_schema("value", &input_schema)?) as _, | ||
| "value".to_string(), | ||
| "value", |
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.
The underlying ProjectionExpr is still the same, this PR just makes it easier to make them
| let projection: Arc<dyn ExecutionPlan> = Arc::new(ProjectionExec::try_new( | ||
| vec![ | ||
| ProjectionExpr::new(Arc::new(Column::new("d", 2)), "d".to_string()), | ||
| ProjectionExpr::new(Arc::new(Column::new("e", 3)), "e".to_string()), |
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.
Why d and e are not simplified here ?
They look exactly the same as a
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.
That is an excellent catch -- done in 99edf9d
Which issue does this PR close?
Rationale for this change
While reviewing the code from @pepijnve in #19287 I noticed it was a little awkward to create
ProjectionExprfrom constants. Let's add a nicer signature for that.Instead of
Do
What changes are included in this PR?
Are these changes tested?
By CI
Are there any user-facing changes?
A slightly nicer API