-
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
Update the type of param_values
to &[ScalarValue]
in function replace_params_with_values
#5640
Conversation
Signed-off-by: remzi <13716567376yh@gmail.com>
Signed-off-by: remzi <13716567376yh@gmail.com>
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.
Thank you @HaoYang670 -- this is a nice improvement
let mut new_exprs = Vec::with_capacity(exprs.len()); | ||
for expr in exprs { | ||
new_exprs.push(Self::replace_placeholders_with_values(expr, param_values)?); | ||
} |
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 think you could make this slightly more idiomatic like this (untested):
let mut new_exprs = Vec::with_capacity(exprs.len()); | |
for expr in exprs { | |
new_exprs.push(Self::replace_placeholders_with_values(expr, param_values)?); | |
} | |
let new_exprs = exprs | |
.into_iter() | |
.map(|expr| Self::replace_placeholders_with_values(expr, param_values)) | |
.collect::<Result<Vec<_>>()?; |
Also, same thing below
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 catching @alamb ! I've updated the code, please review.
Signed-off-by: remzi <13716567376yh@gmail.com>
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.
Looks great @HaoYang670 -- thank you!
@@ -632,22 +631,21 @@ impl LogicalPlan { | |||
/// params_values | |||
pub fn replace_params_with_values( | |||
&self, | |||
param_values: &Vec<ScalarValue>, | |||
param_values: &[ScalarValue], | |||
) -> Result<LogicalPlan, DataFusionError> { |
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.
Perhaps its good to reuse existing Result<LogicalPlan>
which already Result<T, DataFusionError>
. It will make the code less wordy
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.
Thank you @comphead. Actually, I have noticed this, but as we always use Result<_, DatafusionError>
in the file plan.rs
, I didn't change it.
It is a good idea to file an issue to clean the Result<_, DatafusionError>
usages in the project. But I think a more elegant way it to try to implement our own lint so that we can find it during the cargo clippy
.
I've searched how to implement custom lints, but made less progress.
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.
Sounds good, I'll create a separate ticket to clean up. Lints are great ideas, not sure how easy to implement the custom ones
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.
Thank you @comphead. I will also file an issue to track the custom lint
and find if there are more needs in our project to enable it.
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.
#5644 for reference
Thanks @comphead and @HaoYang670 |
Which issue does this PR close?
Closes #5573.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?