Skip to content

Conversation

@corasaurus-hex
Copy link
Contributor

@corasaurus-hex corasaurus-hex commented Nov 8, 2025

Which issue does this PR close?

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_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.

@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Nov 8, 2025
}

/// Create a literal expression
#[allow(clippy::needless_pass_by_value)]
Copy link
Contributor Author

@corasaurus-hex corasaurus-hex Nov 8, 2025

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.

Copy link
Contributor

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.

Copy link
Contributor

@adriangb adriangb left a 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).

@adriangb adriangb added this pull request to the merge queue Nov 9, 2025
Merged via the queue into apache:main with commit a216d4a Nov 9, 2025
33 checks passed
@corasaurus-hex corasaurus-hex deleted the ci-enable-clippy-needless_pass_by_value-datafusion-physical-expr branch November 9, 2025 07:11
codetyri0n pushed a commit to codetyri0n/datafusion that referenced this pull request Nov 11, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce lint rule clippy::needless_pass_by_value to datafusion-physical-expr

2 participants