Skip to content

Commit fc03001

Browse files
alambwaitingkuo
andauthored
Appease clippy (#4101)
Co-authored-by: Wei-Ting Kuo <[email protected]>
1 parent c9442ce commit fc03001

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+218
-247
lines changed

datafusion-examples/examples/dataframe_in_memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ async fn main() -> Result<()> {
3737
let batch = RecordBatch::try_new(
3838
schema,
3939
vec![
40-
Arc::new(StringArray::from_slice(&["a", "b", "c", "d"])),
41-
Arc::new(Int32Array::from_slice(&[1, 10, 10, 100])),
40+
Arc::new(StringArray::from_slice(["a", "b", "c", "d"])),
41+
Arc::new(Int32Array::from_slice([1, 10, 10, 100])),
4242
],
4343
)?;
4444

datafusion-examples/examples/simple_udaf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ fn create_context() -> Result<SessionContext> {
3838
// define data in two partitions
3939
let batch1 = RecordBatch::try_new(
4040
schema.clone(),
41-
vec![Arc::new(Float32Array::from_slice(&[2.0, 4.0, 8.0]))],
41+
vec![Arc::new(Float32Array::from_slice([2.0, 4.0, 8.0]))],
4242
)?;
4343
let batch2 = RecordBatch::try_new(
4444
schema.clone(),
45-
vec![Arc::new(Float32Array::from_slice(&[64.0]))],
45+
vec![Arc::new(Float32Array::from_slice([64.0]))],
4646
)?;
4747

4848
// declare a new context. In spark API, this corresponds to a new spark SQLsession

datafusion-examples/examples/simple_udf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fn create_context() -> Result<SessionContext> {
4242
let batch = RecordBatch::try_new(
4343
schema,
4444
vec![
45-
Arc::new(Float32Array::from_slice(&[2.1, 3.1, 4.1, 5.1])),
46-
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
45+
Arc::new(Float32Array::from_slice([2.1, 3.1, 4.1, 5.1])),
46+
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
4747
],
4848
)?;
4949

datafusion/common/src/bisect.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ mod tests {
9898
#[test]
9999
fn test_bisect_left_and_right() {
100100
let arrays: Vec<ArrayRef> = vec![
101-
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 9., 10.])),
102-
Arc::new(Float64Array::from_slice(&[2.0, 3.0, 3.0, 4.0, 5.0])),
103-
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 10., 11.0])),
104-
Arc::new(Float64Array::from_slice(&[15.0, 13.0, 8.0, 5., 0.0])),
101+
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 9., 10.])),
102+
Arc::new(Float64Array::from_slice([2.0, 3.0, 3.0, 4.0, 5.0])),
103+
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 10., 11.0])),
104+
Arc::new(Float64Array::from_slice([15.0, 13.0, 8.0, 5., 0.0])),
105105
];
106106
let search_tuple: Vec<ScalarValue> = vec![
107107
ScalarValue::Float64(Some(8.0)),
@@ -169,7 +169,7 @@ mod tests {
169169
#[test]
170170
fn test_bisect_left_and_right_diff_sort() {
171171
// Descending, left
172-
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice(&[
172+
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice([
173173
4.0, 3.0, 2.0, 1.0, 0.0,
174174
]))];
175175
let search_tuple: Vec<ScalarValue> = vec![ScalarValue::Float64(Some(4.0))];
@@ -181,7 +181,7 @@ mod tests {
181181
assert_eq!(res, 0);
182182

183183
// Descending, right
184-
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice(&[
184+
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice([
185185
4.0, 3.0, 2.0, 1.0, 0.0,
186186
]))];
187187
let search_tuple: Vec<ScalarValue> = vec![ScalarValue::Float64(Some(4.0))];
@@ -193,9 +193,8 @@ mod tests {
193193
assert_eq!(res, 1);
194194

195195
// Ascending, left
196-
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice(&[
197-
5.0, 7.0, 8.0, 9., 10.,
198-
]))];
196+
let arrays: Vec<ArrayRef> =
197+
vec![Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 9., 10.]))];
199198
let search_tuple: Vec<ScalarValue> = vec![ScalarValue::Float64(Some(7.0))];
200199
let ords = [SortOptions {
201200
descending: false,
@@ -205,9 +204,8 @@ mod tests {
205204
assert_eq!(res, 1);
206205

207206
// Ascending, right
208-
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice(&[
209-
5.0, 7.0, 8.0, 9., 10.,
210-
]))];
207+
let arrays: Vec<ArrayRef> =
208+
vec![Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 9., 10.]))];
211209
let search_tuple: Vec<ScalarValue> = vec![ScalarValue::Float64(Some(7.0))];
212210
let ords = [SortOptions {
213211
descending: false,
@@ -217,8 +215,8 @@ mod tests {
217215
assert_eq!(res, 2);
218216

219217
let arrays: Vec<ArrayRef> = vec![
220-
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 8.0, 9., 10.])),
221-
Arc::new(Float64Array::from_slice(&[10.0, 9.0, 8.0, 7.5, 7., 6.])),
218+
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 8.0, 9., 10.])),
219+
Arc::new(Float64Array::from_slice([10.0, 9.0, 8.0, 7.5, 7., 6.])),
222220
];
223221
let search_tuple: Vec<ScalarValue> = vec![
224222
ScalarValue::Float64(Some(8.0)),

datafusion/common/src/pyarrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl PyArrowConvert for ScalarValue {
3939

4040
// construct pyarrow array from the python value and pyarrow type
4141
let factory = py.import("pyarrow")?.getattr("array")?;
42-
let args = PyList::new(py, &[val]);
42+
let args = PyList::new(py, [val]);
4343
let array = factory.call1((args, typ))?;
4444

4545
// convert the pyarrow array to rust array using C data interface

datafusion/common/src/scalar.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,26 +3432,26 @@ mod tests {
34323432
let expected = Arc::new(StructArray::from(vec![
34333433
(
34343434
field_a.clone(),
3435-
Arc::new(Int32Array::from_slice(&[23, 23])) as ArrayRef,
3435+
Arc::new(Int32Array::from_slice([23, 23])) as ArrayRef,
34363436
),
34373437
(
34383438
field_b.clone(),
3439-
Arc::new(BooleanArray::from_slice(&[false, false])) as ArrayRef,
3439+
Arc::new(BooleanArray::from_slice([false, false])) as ArrayRef,
34403440
),
34413441
(
34423442
field_c.clone(),
3443-
Arc::new(StringArray::from_slice(&["Hello", "Hello"])) as ArrayRef,
3443+
Arc::new(StringArray::from_slice(["Hello", "Hello"])) as ArrayRef,
34443444
),
34453445
(
34463446
field_d.clone(),
34473447
Arc::new(StructArray::from(vec![
34483448
(
34493449
field_e.clone(),
3450-
Arc::new(Int16Array::from_slice(&[2, 2])) as ArrayRef,
3450+
Arc::new(Int16Array::from_slice([2, 2])) as ArrayRef,
34513451
),
34523452
(
34533453
field_f.clone(),
3454-
Arc::new(Int64Array::from_slice(&[3, 3])) as ArrayRef,
3454+
Arc::new(Int64Array::from_slice([3, 3])) as ArrayRef,
34553455
),
34563456
])) as ArrayRef,
34573457
),
@@ -3527,27 +3527,27 @@ mod tests {
35273527
let expected = Arc::new(StructArray::from(vec![
35283528
(
35293529
field_a,
3530-
Arc::new(Int32Array::from_slice(&[23, 7, -1000])) as ArrayRef,
3530+
Arc::new(Int32Array::from_slice([23, 7, -1000])) as ArrayRef,
35313531
),
35323532
(
35333533
field_b,
3534-
Arc::new(BooleanArray::from_slice(&[false, true, true])) as ArrayRef,
3534+
Arc::new(BooleanArray::from_slice([false, true, true])) as ArrayRef,
35353535
),
35363536
(
35373537
field_c,
3538-
Arc::new(StringArray::from_slice(&["Hello", "World", "!!!!!"]))
3538+
Arc::new(StringArray::from_slice(["Hello", "World", "!!!!!"]))
35393539
as ArrayRef,
35403540
),
35413541
(
35423542
field_d,
35433543
Arc::new(StructArray::from(vec![
35443544
(
35453545
field_e,
3546-
Arc::new(Int16Array::from_slice(&[2, 4, 6])) as ArrayRef,
3546+
Arc::new(Int16Array::from_slice([2, 4, 6])) as ArrayRef,
35473547
),
35483548
(
35493549
field_f,
3550-
Arc::new(Int64Array::from_slice(&[3, 5, 7])) as ArrayRef,
3550+
Arc::new(Int64Array::from_slice([3, 5, 7])) as ArrayRef,
35513551
),
35523552
])) as ArrayRef,
35533553
),
@@ -3608,7 +3608,7 @@ mod tests {
36083608
let expected = StructArray::from(vec![
36093609
(
36103610
field_a.clone(),
3611-
Arc::new(StringArray::from_slice(&["First", "Second", "Third"]))
3611+
Arc::new(StringArray::from_slice(["First", "Second", "Third"]))
36123612
as ArrayRef,
36133613
),
36143614
(

datafusion/core/src/datasource/listing/table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl ListingTableConfig {
143143
pub async fn infer_options(self, ctx: &SessionState) -> Result<Self> {
144144
let store = ctx
145145
.runtime_env
146-
.object_store(&self.table_paths.get(0).unwrap())?;
146+
.object_store(self.table_paths.get(0).unwrap())?;
147147

148148
let file = self
149149
.table_paths
@@ -442,7 +442,7 @@ impl ListingTable {
442442
) -> Result<(Vec<Vec<PartitionedFile>>, Statistics)> {
443443
let store = ctx
444444
.runtime_env
445-
.object_store(&self.table_paths.get(0).unwrap())?;
445+
.object_store(self.table_paths.get(0).unwrap())?;
446446
// list files (with partitions)
447447
let file_list = future::try_join_all(self.table_paths.iter().map(|table_path| {
448448
pruned_partition_list(

datafusion/core/src/datasource/memory.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ mod tests {
172172
let batch = RecordBatch::try_new(
173173
schema.clone(),
174174
vec![
175-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
176-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
177-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
175+
Arc::new(Int32Array::from_slice([1, 2, 3])),
176+
Arc::new(Int32Array::from_slice([4, 5, 6])),
177+
Arc::new(Int32Array::from_slice([7, 8, 9])),
178178
Arc::new(Int32Array::from(vec![None, None, Some(9)])),
179179
],
180180
)?;
@@ -209,9 +209,9 @@ mod tests {
209209
let batch = RecordBatch::try_new(
210210
schema.clone(),
211211
vec![
212-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
213-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
214-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
212+
Arc::new(Int32Array::from_slice([1, 2, 3])),
213+
Arc::new(Int32Array::from_slice([4, 5, 6])),
214+
Arc::new(Int32Array::from_slice([7, 8, 9])),
215215
],
216216
)?;
217217

@@ -241,9 +241,9 @@ mod tests {
241241
let batch = RecordBatch::try_new(
242242
schema.clone(),
243243
vec![
244-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
245-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
246-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
244+
Arc::new(Int32Array::from_slice([1, 2, 3])),
245+
Arc::new(Int32Array::from_slice([4, 5, 6])),
246+
Arc::new(Int32Array::from_slice([7, 8, 9])),
247247
],
248248
)?;
249249

@@ -284,9 +284,9 @@ mod tests {
284284
let batch = RecordBatch::try_new(
285285
schema1,
286286
vec![
287-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
288-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
289-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
287+
Arc::new(Int32Array::from_slice([1, 2, 3])),
288+
Arc::new(Int32Array::from_slice([4, 5, 6])),
289+
Arc::new(Int32Array::from_slice([7, 8, 9])),
290290
],
291291
)?;
292292

@@ -317,8 +317,8 @@ mod tests {
317317
let batch = RecordBatch::try_new(
318318
schema1,
319319
vec![
320-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
321-
Arc::new(Int32Array::from_slice(&[7, 5, 9])),
320+
Arc::new(Int32Array::from_slice([1, 2, 3])),
321+
Arc::new(Int32Array::from_slice([7, 5, 9])),
322322
],
323323
)?;
324324

@@ -362,18 +362,18 @@ mod tests {
362362
let batch1 = RecordBatch::try_new(
363363
Arc::new(schema1),
364364
vec![
365-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
366-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
367-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
365+
Arc::new(Int32Array::from_slice([1, 2, 3])),
366+
Arc::new(Int32Array::from_slice([4, 5, 6])),
367+
Arc::new(Int32Array::from_slice([7, 8, 9])),
368368
],
369369
)?;
370370

371371
let batch2 = RecordBatch::try_new(
372372
Arc::new(schema2),
373373
vec![
374-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
375-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
376-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
374+
Arc::new(Int32Array::from_slice([1, 2, 3])),
375+
Arc::new(Int32Array::from_slice([4, 5, 6])),
376+
Arc::new(Int32Array::from_slice([7, 8, 9])),
377377
],
378378
)?;
379379

datafusion/core/src/physical_optimizer/coalesce_batches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl PhysicalOptimizerRule for CoalesceBatches {
4646
fn optimize(
4747
&self,
4848
plan: Arc<dyn crate::physical_plan::ExecutionPlan>,
49-
config: &crate::execution::context::SessionConfig,
49+
_config: &crate::execution::context::SessionConfig,
5050
) -> Result<Arc<dyn crate::physical_plan::ExecutionPlan>> {
5151
if plan.children().is_empty() {
5252
// leaf node, children cannot be replaced
@@ -56,7 +56,7 @@ impl PhysicalOptimizerRule for CoalesceBatches {
5656
let children = plan
5757
.children()
5858
.iter()
59-
.map(|child| self.optimize(child.clone(), config))
59+
.map(|child| self.optimize(child.clone(), _config))
6060
.collect::<Result<Vec<_>>>()?;
6161
let plan = with_new_children_if_necessary(plan, children)?;
6262
// The goal here is to detect operators that could produce small batches and only

datafusion/core/src/physical_optimizer/merge_exec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl PhysicalOptimizerRule for AddCoalescePartitionsExec {
4141
fn optimize(
4242
&self,
4343
plan: Arc<dyn crate::physical_plan::ExecutionPlan>,
44-
config: &crate::execution::context::SessionConfig,
44+
_config: &crate::execution::context::SessionConfig,
4545
) -> Result<Arc<dyn crate::physical_plan::ExecutionPlan>> {
4646
if plan.children().is_empty() {
4747
// leaf node, children cannot be replaced
@@ -50,7 +50,7 @@ impl PhysicalOptimizerRule for AddCoalescePartitionsExec {
5050
let children = plan
5151
.children()
5252
.iter()
53-
.map(|child| self.optimize(child.clone(), config))
53+
.map(|child| self.optimize(child.clone(), _config))
5454
.collect::<Result<Vec<_>>>()?;
5555
match plan.required_child_distribution() {
5656
Distribution::UnspecifiedDistribution => {

datafusion/core/src/physical_optimizer/pruning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ mod tests {
12191219

12201220
// Note the statistics return binary (which can't be cast to string)
12211221
let statistics = OneContainerStats {
1222-
min_values: Some(Arc::new(BinaryArray::from_slice(&[&[255u8] as &[u8]]))),
1222+
min_values: Some(Arc::new(BinaryArray::from_slice([&[255u8] as &[u8]]))),
12231223
max_values: None,
12241224
num_containers: 1,
12251225
};

datafusion/core/src/physical_plan/aggregates/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,16 +683,16 @@ mod tests {
683683
RecordBatch::try_new(
684684
schema.clone(),
685685
vec![
686-
Arc::new(UInt32Array::from_slice(&[2, 3, 4, 4])),
687-
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
686+
Arc::new(UInt32Array::from_slice([2, 3, 4, 4])),
687+
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
688688
],
689689
)
690690
.unwrap(),
691691
RecordBatch::try_new(
692692
schema,
693693
vec![
694-
Arc::new(UInt32Array::from_slice(&[2, 3, 3, 4])),
695-
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
694+
Arc::new(UInt32Array::from_slice([2, 3, 3, 4])),
695+
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
696696
],
697697
)
698698
.unwrap(),

datafusion/core/src/physical_plan/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ mod tests {
366366
let batch = RecordBatch::try_new(
367367
Arc::clone(&schema),
368368
vec![
369-
Arc::new(Float32Array::from_slice(&[1., 2., 3.])),
370-
Arc::new(Float64Array::from_slice(&[9., 8., 7.])),
369+
Arc::new(Float32Array::from_slice([1., 2., 3.])),
370+
Arc::new(Float64Array::from_slice([9., 8., 7.])),
371371
],
372372
)?;
373373
let actual =

datafusion/core/src/physical_plan/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ mod tests {
238238
let batch = RecordBatch::try_new(
239239
schema.clone(),
240240
vec![
241-
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
242-
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
241+
Arc::new(Int32Array::from_slice([1, 2, 3])),
242+
Arc::new(Int32Array::from_slice([4, 5, 6])),
243243
Arc::new(Int32Array::from(vec![None, None, Some(9)])),
244-
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
244+
Arc::new(Int32Array::from_slice([7, 8, 9])),
245245
],
246246
)?;
247247

0 commit comments

Comments
 (0)