Skip to content
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

Appease new clippy #4101

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion-examples/examples/dataframe_in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ async fn main() -> Result<()> {
let batch = RecordBatch::try_new(
schema,
vec![
Arc::new(StringArray::from_slice(&["a", "b", "c", "d"])),
Arc::new(Int32Array::from_slice(&[1, 10, 10, 100])),
Arc::new(StringArray::from_slice(["a", "b", "c", "d"])),
Arc::new(Int32Array::from_slice([1, 10, 10, 100])),
],
)?;

Expand Down
4 changes: 2 additions & 2 deletions datafusion-examples/examples/simple_udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ fn create_context() -> Result<SessionContext> {
// define data in two partitions
let batch1 = RecordBatch::try_new(
schema.clone(),
vec![Arc::new(Float32Array::from_slice(&[2.0, 4.0, 8.0]))],
vec![Arc::new(Float32Array::from_slice([2.0, 4.0, 8.0]))],
)?;
let batch2 = RecordBatch::try_new(
schema.clone(),
vec![Arc::new(Float32Array::from_slice(&[64.0]))],
vec![Arc::new(Float32Array::from_slice([64.0]))],
)?;

// declare a new context. In spark API, this corresponds to a new spark SQLsession
Expand Down
4 changes: 2 additions & 2 deletions datafusion-examples/examples/simple_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fn create_context() -> Result<SessionContext> {
let batch = RecordBatch::try_new(
schema,
vec![
Arc::new(Float32Array::from_slice(&[2.1, 3.1, 4.1, 5.1])),
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
Arc::new(Float32Array::from_slice([2.1, 3.1, 4.1, 5.1])),
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
],
)?;

Expand Down
26 changes: 12 additions & 14 deletions datafusion/common/src/bisect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ mod tests {
#[test]
fn test_bisect_left_and_right() {
let arrays: Vec<ArrayRef> = vec![
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 9., 10.])),
Arc::new(Float64Array::from_slice(&[2.0, 3.0, 3.0, 4.0, 5.0])),
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 10., 11.0])),
Arc::new(Float64Array::from_slice(&[15.0, 13.0, 8.0, 5., 0.0])),
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 9., 10.])),
Arc::new(Float64Array::from_slice([2.0, 3.0, 3.0, 4.0, 5.0])),
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 10., 11.0])),
Arc::new(Float64Array::from_slice([15.0, 13.0, 8.0, 5., 0.0])),
];
let search_tuple: Vec<ScalarValue> = vec![
ScalarValue::Float64(Some(8.0)),
Expand Down Expand Up @@ -169,7 +169,7 @@ mod tests {
#[test]
fn test_bisect_left_and_right_diff_sort() {
// Descending, left
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice(&[
let arrays: Vec<ArrayRef> = vec![Arc::new(Float64Array::from_slice([
4.0, 3.0, 2.0, 1.0, 0.0,
]))];
let search_tuple: Vec<ScalarValue> = vec![ScalarValue::Float64(Some(4.0))];
Expand All @@ -181,7 +181,7 @@ mod tests {
assert_eq!(res, 0);

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

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

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

let arrays: Vec<ArrayRef> = vec![
Arc::new(Float64Array::from_slice(&[5.0, 7.0, 8.0, 8.0, 9., 10.])),
Arc::new(Float64Array::from_slice(&[10.0, 9.0, 8.0, 7.5, 7., 6.])),
Arc::new(Float64Array::from_slice([5.0, 7.0, 8.0, 8.0, 9., 10.])),
Arc::new(Float64Array::from_slice([10.0, 9.0, 8.0, 7.5, 7., 6.])),
];
let search_tuple: Vec<ScalarValue> = vec![
ScalarValue::Float64(Some(8.0)),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/common/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl PyArrowConvert for ScalarValue {

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

// convert the pyarrow array to rust array using C data interface
Expand Down
22 changes: 11 additions & 11 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3432,26 +3432,26 @@ mod tests {
let expected = Arc::new(StructArray::from(vec![
(
field_a.clone(),
Arc::new(Int32Array::from_slice(&[23, 23])) as ArrayRef,
Arc::new(Int32Array::from_slice([23, 23])) as ArrayRef,
),
(
field_b.clone(),
Arc::new(BooleanArray::from_slice(&[false, false])) as ArrayRef,
Arc::new(BooleanArray::from_slice([false, false])) as ArrayRef,
),
(
field_c.clone(),
Arc::new(StringArray::from_slice(&["Hello", "Hello"])) as ArrayRef,
Arc::new(StringArray::from_slice(["Hello", "Hello"])) as ArrayRef,
),
(
field_d.clone(),
Arc::new(StructArray::from(vec![
(
field_e.clone(),
Arc::new(Int16Array::from_slice(&[2, 2])) as ArrayRef,
Arc::new(Int16Array::from_slice([2, 2])) as ArrayRef,
),
(
field_f.clone(),
Arc::new(Int64Array::from_slice(&[3, 3])) as ArrayRef,
Arc::new(Int64Array::from_slice([3, 3])) as ArrayRef,
),
])) as ArrayRef,
),
Expand Down Expand Up @@ -3527,27 +3527,27 @@ mod tests {
let expected = Arc::new(StructArray::from(vec![
(
field_a,
Arc::new(Int32Array::from_slice(&[23, 7, -1000])) as ArrayRef,
Arc::new(Int32Array::from_slice([23, 7, -1000])) as ArrayRef,
),
(
field_b,
Arc::new(BooleanArray::from_slice(&[false, true, true])) as ArrayRef,
Arc::new(BooleanArray::from_slice([false, true, true])) as ArrayRef,
),
(
field_c,
Arc::new(StringArray::from_slice(&["Hello", "World", "!!!!!"]))
Arc::new(StringArray::from_slice(["Hello", "World", "!!!!!"]))
as ArrayRef,
),
(
field_d,
Arc::new(StructArray::from(vec![
(
field_e,
Arc::new(Int16Array::from_slice(&[2, 4, 6])) as ArrayRef,
Arc::new(Int16Array::from_slice([2, 4, 6])) as ArrayRef,
),
(
field_f,
Arc::new(Int64Array::from_slice(&[3, 5, 7])) as ArrayRef,
Arc::new(Int64Array::from_slice([3, 5, 7])) as ArrayRef,
),
])) as ArrayRef,
),
Expand Down Expand Up @@ -3608,7 +3608,7 @@ mod tests {
let expected = StructArray::from(vec![
(
field_a.clone(),
Arc::new(StringArray::from_slice(&["First", "Second", "Third"]))
Arc::new(StringArray::from_slice(["First", "Second", "Third"]))
as ArrayRef,
),
(
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl ListingTableConfig {
pub async fn infer_options(self, ctx: &SessionState) -> Result<Self> {
let store = ctx
.runtime_env
.object_store(&self.table_paths.get(0).unwrap())?;
.object_store(self.table_paths.get(0).unwrap())?;

let file = self
.table_paths
Expand Down Expand Up @@ -442,7 +442,7 @@ impl ListingTable {
) -> Result<(Vec<Vec<PartitionedFile>>, Statistics)> {
let store = ctx
.runtime_env
.object_store(&self.table_paths.get(0).unwrap())?;
.object_store(self.table_paths.get(0).unwrap())?;
// list files (with partitions)
let file_list = future::try_join_all(self.table_paths.iter().map(|table_path| {
pruned_partition_list(
Expand Down
40 changes: 20 additions & 20 deletions datafusion/core/src/datasource/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
Arc::new(Int32Array::from(vec![None, None, Some(9)])),
],
)?;
Expand Down Expand Up @@ -209,9 +209,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

Expand Down Expand Up @@ -241,9 +241,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

Expand Down Expand Up @@ -284,9 +284,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema1,
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

Expand Down Expand Up @@ -317,8 +317,8 @@ mod tests {
let batch = RecordBatch::try_new(
schema1,
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[7, 5, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([7, 5, 9])),
],
)?;

Expand Down Expand Up @@ -362,18 +362,18 @@ mod tests {
let batch1 = RecordBatch::try_new(
Arc::new(schema1),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

let batch2 = RecordBatch::try_new(
Arc::new(schema2),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/physical_optimizer/coalesce_batches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl PhysicalOptimizerRule for CoalesceBatches {
fn optimize(
&self,
plan: Arc<dyn crate::physical_plan::ExecutionPlan>,
config: &crate::execution::context::SessionConfig,
_config: &crate::execution::context::SessionConfig,
) -> Result<Arc<dyn crate::physical_plan::ExecutionPlan>> {
if plan.children().is_empty() {
// leaf node, children cannot be replaced
Expand All @@ -56,7 +56,7 @@ impl PhysicalOptimizerRule for CoalesceBatches {
let children = plan
.children()
.iter()
.map(|child| self.optimize(child.clone(), config))
.map(|child| self.optimize(child.clone(), _config))
.collect::<Result<Vec<_>>>()?;
let plan = with_new_children_if_necessary(plan, children)?;
// The goal here is to detect operators that could produce small batches and only
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/physical_optimizer/merge_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl PhysicalOptimizerRule for AddCoalescePartitionsExec {
fn optimize(
&self,
plan: Arc<dyn crate::physical_plan::ExecutionPlan>,
config: &crate::execution::context::SessionConfig,
_config: &crate::execution::context::SessionConfig,
) -> Result<Arc<dyn crate::physical_plan::ExecutionPlan>> {
if plan.children().is_empty() {
// leaf node, children cannot be replaced
Expand All @@ -50,7 +50,7 @@ impl PhysicalOptimizerRule for AddCoalescePartitionsExec {
let children = plan
.children()
.iter()
.map(|child| self.optimize(child.clone(), config))
.map(|child| self.optimize(child.clone(), _config))
.collect::<Result<Vec<_>>>()?;
match plan.required_child_distribution() {
Distribution::UnspecifiedDistribution => {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ mod tests {

// Note the statistics return binary (which can't be cast to string)
let statistics = OneContainerStats {
min_values: Some(Arc::new(BinaryArray::from_slice(&[&[255u8] as &[u8]]))),
min_values: Some(Arc::new(BinaryArray::from_slice([&[255u8] as &[u8]]))),
max_values: None,
num_containers: 1,
};
Expand Down
8 changes: 4 additions & 4 deletions datafusion/core/src/physical_plan/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,16 @@ mod tests {
RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(UInt32Array::from_slice(&[2, 3, 4, 4])),
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
Arc::new(UInt32Array::from_slice([2, 3, 4, 4])),
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
],
)
.unwrap(),
RecordBatch::try_new(
schema,
vec![
Arc::new(UInt32Array::from_slice(&[2, 3, 3, 4])),
Arc::new(Float64Array::from_slice(&[1.0, 2.0, 3.0, 4.0])),
Arc::new(UInt32Array::from_slice([2, 3, 3, 4])),
Arc::new(Float64Array::from_slice([1.0, 2.0, 3.0, 4.0])),
],
)
.unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/physical_plan/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ mod tests {
let batch = RecordBatch::try_new(
Arc::clone(&schema),
vec![
Arc::new(Float32Array::from_slice(&[1., 2., 3.])),
Arc::new(Float64Array::from_slice(&[9., 8., 7.])),
Arc::new(Float32Array::from_slice([1., 2., 3.])),
Arc::new(Float64Array::from_slice([9., 8., 7.])),
],
)?;
let actual =
Expand Down
6 changes: 3 additions & 3 deletions datafusion/core/src/physical_plan/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ mod tests {
let batch = RecordBatch::try_new(
schema.clone(),
vec![
Arc::new(Int32Array::from_slice(&[1, 2, 3])),
Arc::new(Int32Array::from_slice(&[4, 5, 6])),
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from(vec![None, None, Some(9)])),
Arc::new(Int32Array::from_slice(&[7, 8, 9])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
],
)?;

Expand Down
Loading