-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use a struct for ProjectionExpr #17398
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
alamb
left a comment
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.
Thanks @adriangb
I agree this is a nicer API. The only think I worry about is the disruption to existing users .
I left a suggestion that I think would reduce the API churn needed substantially. Let me know what you think
| (col("c1", schema.as_ref()).unwrap(), "c1".to_string()), | ||
| (col("c2", schema.as_ref()).unwrap(), "c2".to_string()), | ||
| (col("c3", schema.as_ref()).unwrap(), "c3".to_string()), | ||
| ProjectionExpr { |
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.
We might be able to make the API change easier to handle by using a From impl:
so like instead of
vec![
(col("c1", schema.as_ref()).unwrap(), "c1".to_string()),
]something like
vec![
ProjectionExpr::from(col("c1", schema.as_ref()).unwrap(), "c1".to_string()),
]This would mean that people upgrading could simply add ProjectionExpr::from
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.
Going one step farther, I think we could make ProjectionExec generic, like this
impl ProjectionExec {
/// Create a projection on an input
pub fn try_new(
expr: impl IntoIterator<Item=ProjectionExpr>,
input: Arc<dyn ExecutionPlan>,
) -> Result<Self> {That would let people use the same code mostly without change
Update: I tried it out and it seems to work pretty well. Check out
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.
Nice yeah I was thinking of doing that but thought it best to update our internal tests anyway.
The unfortunate part is that there's no way to mark an implementation as deprecated: ideally we'd allow this for a couple releases then remove it to simplify things, but that's not possible. I guess we keep it around forever.
* Keep ProjectionExec mostly backwards compatible * Add doc examples and explicit test for old API
#17395 (comment)
This makes code more legible and easier to follow.