-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: Enforce lint rule clippy::needless_pass_by_value to datafusion-physical-expr
#18557
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
chore: Enforce lint rule clippy::needless_pass_by_value to datafusion-physical-expr
#18557
Conversation
…ion-physical-expr`
| } | ||
|
|
||
| /// Create a literal expression | ||
| #[allow(clippy::needless_pass_by_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.
Changing this to be &T produced the following errors:
❯ ./ci/scripts/rust_clippy.sh 2>&1 | grep '^error\[' -A1 | grep '^ ' | sort | grep -o -E 'datafusion[^:]+' | uniq -c | sort -n | awk '{ print $1, "error(s)\t", $2}
1 error(s) datafusion/physical-expr/src/planner.rs
2 error(s) datafusion/physical-expr/src/expressions/literal.rs
3 error(s) datafusion/physical-expr/src/simplifier/mod.rs
4 error(s) datafusion/physical-expr/src/utils/mod.rs
5 error(s) datafusion/physical-expr/src/equivalence/class.rs
6 error(s) datafusion/physical-expr/src/expressions/dynamic_filters.rs
18 error(s) datafusion/physical-expr/src/simplifier/unwrap_cast.rs
22 error(s) datafusion/physical-expr/src/expressions/binary.rs
62 error(s) datafusion/physical-expr/src/expressions/in_list.rs
79 error(s) datafusion/physical-expr/src/expressions/case.rs
82 error(s) datafusion/physical-expr/src/expressions/in_list.rs
❯ ./ci/scripts/rust_clippy.sh 2>&1 | grep '^error\[' | sort | uniq -c | sort -n
1 error[E0599]: the method `collect` exists for struct `Map<Range<i32>, fn(&_) -> Arc<dyn PhysicalExpr> {lit::<_>}>`, but its trait bounds were not satisfied
1 error[E0631]: type mismatch in function arguments
4 error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
4 error[E0277]: the trait bound `[{integer}]: datafusion_expr::Literal` is not satisfied
39 error[E0277]: the size for values of type `str` cannot be known at compilation time
39 error[E0277]: the trait bound `str: datafusion_expr::Literal` is not satisfied
196 error[E0308]: mismatched types
It's exposed publicly, too, and likely used in a lot of user code. Definitely not worth modifying.
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 for catching this and for pointing it out for reviewers.
adriangb
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 you! I'm going to go ahead and merge this since it's a straightforward change to enforce an automated rule that we already agreed to roll out (tracked in #18503).
…ion-physical-expr` (apache#18557) ## 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 apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#18544. ## 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. --> See apache#18503 for details. ## 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. --> I enabled the clippy lint rule and then fixed nearly all instances. ## 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)? --> As part of the normal test suite, yes. ## 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. --> The following `pub (crate)` APIs were changed: - `regex_match_dyn` in `datafusion/physical-expr/src/expressions/binary/kernels.rs` - `regex_match_dyn_scalar` in `datafusion/physical-expr/src/expressions/binary/kernels.rs` But no fully `pub` functions were changed.
Which issue does this PR close?
clippy::needless_pass_by_valuetodatafusion-physical-expr#18544.Rationale for this change
See #18503 for details.
What changes are included in this PR?
I enabled the clippy lint rule and then fixed nearly all instances.
Are these changes tested?
As part of the normal test suite, yes.
Are there any user-facing changes?
The following
pub (crate)APIs were changed:regex_match_dynindatafusion/physical-expr/src/expressions/binary/kernels.rsregex_match_dyn_scalarindatafusion/physical-expr/src/expressions/binary/kernels.rsBut no fully
pubfunctions were changed.