Commit 1586cab
feat: added clippy::needless_pass_by_value lint rule to datafusion/expr (#18532)
## Which issue does this PR close?
- Closes #18504.
## Rationale for this change
Followed suggestions to not update any public-facing APIs and put the
lint rule in the appropriate spot.
## What changes are included in this PR?
* Add `#![deny(clippy::needless_pass_by_value)]` and `#![cfg_attr(test,
allow(clippy::needless_pass_by_value))]` to `lib.rs`.
* Add `#[allow(clippy::needless_pass_by_value)]` to public functions
* fix `rewrite_in_terms_of_projection()` and
`get_exprs_except_skipped()` to use references per the lint suggestion
## Are these changes tested?
Yes, though the same test failed even without changes to the public
APIs:
`test expr_rewriter::order_by::test::rewrite_sort_cols_by_agg_alias ...
FAILED`
I'll append the logs for your convenience:
```
failures:
---- expr_rewriter::order_by::test::rewrite_sort_cols_by_agg_alias stdout ----
running: 'c1 --> c1 -- column *named* c1 that came out of the projection, (not t.c1)'
running: 'min(c2) --> "min(c2)" -- (column *named* "min(t.c2)"!)'
thread 'expr_rewriter::order_by::test::rewrite_sort_cols_by_agg_alias' (27524241) panicked at datafusion/expr/src/expr_rewriter/order_by.rs:308:13:
assertion `left == right` failed:
input:Sort { expr: AggregateFunction(AggregateFunction { func: AggregateUDF { inner: Min { name: "min", signature: Signature { type_signature: VariadicAny, volatility: Immutable, parameter_names: None } } }, params: AggregateFunctionParams { args: [Column(Column { relation: None, name: "c2" })], distinct: false, filter: None, order_by: [], null_treatment: None } }), asc: true, nulls_first: true }
rewritten:Sort { expr: Column(Column { relation: None, name: "min(t.c2)" }), asc: true, nulls_first: true }
expected:Sort { expr: Column(Column { relation: Some(Bare { table: "min(t" }), name: "c2)" }), asc: true, nulls_first: true }
left: Sort { expr: Column(Column { relation: None, name: "min(t.c2)" }), asc: true, nulls_first: true }
right: Sort { expr: Column(Column { relation: Some(Bare { table: "min(t" }), name: "c2)" }), asc: true, nulls_first: true }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
expr_rewriter::order_by::test::rewrite_sort_cols_by_agg_alias
```
## Are there any user-facing changes?
No, all modification were constrained to internal APIs.
---------
Co-authored-by: Yongting You <[email protected]>1 parent f162fd3 commit 1586cab
File tree
6 files changed
+15
-6
lines changed- datafusion/expr/src
- expr_rewriter
- logical_plan
6 files changed
+15
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3481 | 3481 | | |
3482 | 3482 | | |
3483 | 3483 | | |
| 3484 | + | |
3484 | 3485 | | |
3485 | 3486 | | |
3486 | 3487 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
928 | 928 | | |
929 | 929 | | |
930 | 930 | | |
| 931 | + | |
931 | 932 | | |
932 | 933 | | |
933 | 934 | | |
| |||
0 commit comments