You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "HaoYang670 (via GitHub)" <gi...@apache.org> on 2023/03/19 06:10:01 UTC

[GitHub] [arrow-datafusion] HaoYang670 opened a new pull request, #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

HaoYang670 opened a new pull request, #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5573.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141338823


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -632,16 +632,16 @@ impl LogicalPlan {
     /// params_values
     pub fn replace_params_with_values(
         &self,
-        param_values: &Vec<ScalarValue>,
+        param_values: &[ScalarValue],
     ) -> Result<LogicalPlan, DataFusionError> {
         let exprs = self.expressions();
-        let mut new_exprs = vec![];
+        let mut new_exprs = Vec::with_capacity(exprs.len());
         for expr in exprs {
             new_exprs.push(Self::replace_placeholders_with_values(expr, param_values)?);
         }

Review Comment:
   I think you could make this slightly more idiomatic like this (untested):
   ```suggestion
           let new_exprs = exprs
             .into_iter()
             .map(|expr| Self::replace_placeholders_with_values(expr, param_values))
             .collect::<Result<Vec<_>>()?;
   ```
   
   Also, same thing below



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] HaoYang670 commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "HaoYang670 (via GitHub)" <gi...@apache.org>.
HaoYang670 commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141546182


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -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> {

Review Comment:
   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.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141433380


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -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> {

Review Comment:
   Perhaps its good to reuse existing `Result<LogicalPlan>` which already `Result<T, DataFusionError>`. It will make the code less wordy



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] HaoYang670 commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "HaoYang670 (via GitHub)" <gi...@apache.org>.
HaoYang670 commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141345606


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -632,16 +632,16 @@ impl LogicalPlan {
     /// params_values
     pub fn replace_params_with_values(
         &self,
-        param_values: &Vec<ScalarValue>,
+        param_values: &[ScalarValue],
     ) -> Result<LogicalPlan, DataFusionError> {
         let exprs = self.expressions();
-        let mut new_exprs = vec![];
+        let mut new_exprs = Vec::with_capacity(exprs.len());
         for expr in exprs {
             new_exprs.push(Self::replace_placeholders_with_values(expr, param_values)?);
         }

Review Comment:
   Nice catching @alamb ! I've updated the code, please review.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141604196


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -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> {

Review Comment:
   Sounds good, I'll create a separate ticket to clean up. Lints are great ideas, not sure how easy to implement the custom ones



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#issuecomment-1476061718

   Thanks @comphead  and @HaoYang670 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] HaoYang670 commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "HaoYang670 (via GitHub)" <gi...@apache.org>.
HaoYang670 commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141605774


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -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> {

Review Comment:
   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.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5640: Update the type of `param_values` to `&[ScalarValue]` in function `replace_params_with_values`

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5640:
URL: https://github.com/apache/arrow-datafusion/pull/5640#discussion_r1141980972


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -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> {

Review Comment:
   https://github.com/apache/arrow-datafusion/issues/5644 for reference



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org