Skip to content

Apache DataFusion SQL Query Engine

ARROW-10740: [Rust][DataFusion] Remove redundant clones found by clippy

Heres, Daniel7d39836d5eea
diff --git a/rust/datafusion/src/datasource/memory.rs b/rust/datafusion/src/datasource/memory.rs
index 12db5b5e9e..19efa0a1d8 100644
--- a/rust/datafusion/src/datasource/memory.rs
+++ b/rust/datafusion/src/datasource/memory.rs
@@ -241,7 +241,7 @@ mod tests {
]));
let batch = RecordBatch::try_new(
- schema1.clone(),
+ schema1,
vec![
Arc::new(Int32Array::from(vec![1, 2, 3])),
Arc::new(Int32Array::from(vec![4, 5, 6])),
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index 03973aadf3..37eb9ec19f 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -210,11 +210,11 @@ impl ExecutionContext {
let table_scan = LogicalPlan::CsvScan {
path: filename.to_string(),
- schema: csv.schema().clone(),
+ schema: csv.schema(),
has_header: options.has_header,
delimiter: Some(options.delimiter),
projection: None,
- projected_schema: csv.schema().clone(),
+ projected_schema: csv.schema(),
};
Ok(Arc::new(DataFrameImpl::new(
@@ -229,9 +229,9 @@ impl ExecutionContext {
let table_scan = LogicalPlan::ParquetScan {
path: filename.to_string(),
- schema: parquet.schema().clone(),
+ schema: parquet.schema(),
projection: None,
- projected_schema: parquet.schema().clone(),
+ projected_schema: parquet.schema(),
};
Ok(Arc::new(DataFrameImpl::new(
@@ -245,7 +245,7 @@ impl ExecutionContext {
&mut self,
provider: Arc<dyn TableProvider + Send + Sync>,
) -> Result<Arc<dyn DataFrame>> {
- let schema = provider.schema().clone();
+ let schema = provider.schema();
let table_scan = LogicalPlan::TableScan {
schema_name: "".to_string(),
source: TableSource::FromProvider(provider),
@@ -297,7 +297,7 @@ impl ExecutionContext {
pub fn table(&mut self, table_name: &str) -> Result<Arc<dyn DataFrame>> {
match self.state.datasources.get(table_name) {
Some(provider) => {
- let schema = provider.schema().clone();
+ let schema = provider.schema();
let table_scan = LogicalPlan::TableScan {
schema_name: "".to_string(),
source: TableSource::FromContext(table_name.to_string()),
@@ -530,7 +530,7 @@ pub struct ExecutionContextState {
impl SchemaProvider for ExecutionContextState {
fn get_table_meta(&self, name: &str) -> Option<SchemaRef> {
- self.datasources.get(name).map(|ds| ds.schema().clone())
+ self.datasources.get(name).map(|ds| ds.schema())
}
fn get_function_meta(&self, name: &str) -> Option<Arc<ScalarUDF>> {
@@ -554,9 +554,10 @@ impl FunctionRegistry for ExecutionContextState {
fn udf(&self, name: &str) -> Result<&ScalarUDF> {
let result = self.scalar_functions.get(name);
if result.is_none() {
- Err(DataFusionError::Plan(
- format!("There is no UDF named \"{}\" in the registry", name).to_string(),
- ))
+ Err(DataFusionError::Plan(format!(
+ "There is no UDF named \"{}\" in the registry",
+ name
+ )))
} else {
Ok(result.unwrap())
}
@@ -565,10 +566,10 @@ impl FunctionRegistry for ExecutionContextState {
fn udaf(&self, name: &str) -> Result<&AggregateUDF> {
let result = self.aggregate_functions.get(name);
if result.is_none() {
- Err(DataFusionError::Plan(
- format!("There is no UDAF named \"{}\" in the registry", name)
- .to_string(),
- ))
+ Err(DataFusionError::Plan(format!(
+ "There is no UDAF named \"{}\" in the registry",
+ name
+ )))
} else {
Ok(result.unwrap())
}
diff --git a/rust/datafusion/src/execution/dataframe_impl.rs b/rust/datafusion/src/execution/dataframe_impl.rs
index fde96b4a61..d7141d4556 100644
--- a/rust/datafusion/src/execution/dataframe_impl.rs
+++ b/rust/datafusion/src/execution/dataframe_impl.rs
@@ -203,7 +203,7 @@ mod tests {
count(col("c12")),
];
- let df = df.aggregate(group_expr.clone(), aggr_expr.clone())?;
+ let df = df.aggregate(group_expr, aggr_expr)?;
let plan = df.to_logical_plan();
diff --git a/rust/datafusion/src/lib.rs b/rust/datafusion/src/lib.rs
index e90086ee22..4e4222d97d 100644
--- a/rust/datafusion/src/lib.rs
+++ b/rust/datafusion/src/lib.rs
@@ -40,7 +40,6 @@
clippy::new_without_default,
clippy::or_fun_call,
clippy::ptr_arg,
- clippy::redundant_clone,
clippy::redundant_field_names,
clippy::redundant_static_lifetimes,
clippy::redundant_pattern_matching,
diff --git a/rust/datafusion/src/logical_plan/builder.rs b/rust/datafusion/src/logical_plan/builder.rs
index d182a5d845..08aa4ac60c 100644
--- a/rust/datafusion/src/logical_plan/builder.rs
+++ b/rust/datafusion/src/logical_plan/builder.rs
@@ -92,7 +92,7 @@ impl LogicalPlanBuilder {
/// Scan a Parquet data source
pub fn scan_parquet(path: &str, projection: Option<Vec<usize>>) -> Result<Self> {
let p = ParquetTable::try_new(path)?;
- let schema = p.schema().clone();
+ let schema = p.schema();
let projected_schema = projection
.clone()
diff --git a/rust/datafusion/src/logical_plan/expr.rs b/rust/datafusion/src/logical_plan/expr.rs
index 509285b2b4..78b2e60e1f 100644
--- a/rust/datafusion/src/logical_plan/expr.rs
+++ b/rust/datafusion/src/logical_plan/expr.rs
@@ -305,32 +305,32 @@ impl Expr {
/// Equal
pub fn eq(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::Eq, other.clone())
+ binary_expr(self.clone(), Operator::Eq, other)
}
/// Not equal
pub fn not_eq(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::NotEq, other.clone())
+ binary_expr(self.clone(), Operator::NotEq, other)
}
/// Greater than
pub fn gt(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::Gt, other.clone())
+ binary_expr(self.clone(), Operator::Gt, other)
}
/// Greater than or equal to
pub fn gt_eq(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::GtEq, other.clone())
+ binary_expr(self.clone(), Operator::GtEq, other)
}
/// Less than
pub fn lt(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::Lt, other.clone())
+ binary_expr(self.clone(), Operator::Lt, other)
}
/// Less than or equal to
pub fn lt_eq(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::LtEq, other.clone())
+ binary_expr(self.clone(), Operator::LtEq, other)
}
/// And
@@ -350,17 +350,17 @@ impl Expr {
/// Calculate the modulus of two expressions
pub fn modulus(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::Modulus, other.clone())
+ binary_expr(self.clone(), Operator::Modulus, other)
}
/// like (string) another expression
pub fn like(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::Like, other.clone())
+ binary_expr(self.clone(), Operator::Like, other)
}
/// not like another expression
pub fn not_like(&self, other: Expr) -> Expr {
- binary_expr(self.clone(), Operator::NotLike, other.clone())
+ binary_expr(self.clone(), Operator::NotLike, other)
}
/// Alias
@@ -807,13 +807,13 @@ fn create_name(e: &Expr, input_schema: &Schema) -> Result<String> {
} => {
let mut name = "CASE ".to_string();
if let Some(e) = expr {
- name += &format!("{:?} ", e).to_string();
+ name += &format!("{:?} ", e);
}
for (w, t) in when_then_expr {
- name += &format!("WHEN {:?} THEN {:?} ", w, t).to_string();
+ name += &format!("WHEN {:?} THEN {:?} ", w, t);
}
if let Some(e) = else_expr {
- name += &format!("ELSE {:?} ", e).to_string();
+ name += &format!("ELSE {:?} ", e);
}
name += "END";
Ok(name)
diff --git a/rust/datafusion/src/logical_plan/operators.rs b/rust/datafusion/src/logical_plan/operators.rs
index f002d01314..b59462f73d 100644
--- a/rust/datafusion/src/logical_plan/operators.rs
+++ b/rust/datafusion/src/logical_plan/operators.rs
@@ -81,7 +81,7 @@ impl ops::Add for Expr {
type Output = Self;
fn add(self, rhs: Self) -> Self {
- binary_expr(self.clone(), Operator::Plus, rhs.clone())
+ binary_expr(self, Operator::Plus, rhs)
}
}
@@ -89,7 +89,7 @@ impl ops::Sub for Expr {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
- binary_expr(self.clone(), Operator::Minus, rhs.clone())
+ binary_expr(self, Operator::Minus, rhs)
}
}
@@ -97,7 +97,7 @@ impl ops::Mul for Expr {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
- binary_expr(self.clone(), Operator::Multiply, rhs.clone())
+ binary_expr(self, Operator::Multiply, rhs)
}
}
@@ -105,7 +105,7 @@ impl ops::Div for Expr {
type Output = Self;
fn div(self, rhs: Self) -> Self {
- binary_expr(self.clone(), Operator::Divide, rhs.clone())
+ binary_expr(self, Operator::Divide, rhs)
}
}
diff --git a/rust/datafusion/src/optimizer/filter_push_down.rs b/rust/datafusion/src/optimizer/filter_push_down.rs
index f1b7fc31ea..71af928ebe 100644
--- a/rust/datafusion/src/optimizer/filter_push_down.rs
+++ b/rust/datafusion/src/optimizer/filter_push_down.rs
@@ -99,7 +99,7 @@ fn issue_filters(
// add a new filter node with the predicates
let plan = LogicalPlan::Filter {
- predicate: predicate.clone(),
+ predicate,
input: Arc::new(plan.clone()),
};
diff --git a/rust/datafusion/src/physical_plan/csv.rs b/rust/datafusion/src/physical_plan/csv.rs
index f28523fc46..857e874d98 100644
--- a/rust/datafusion/src/physical_plan/csv.rs
+++ b/rust/datafusion/src/physical_plan/csv.rs
@@ -252,7 +252,7 @@ impl CsvStream {
let file = File::open(filename)?;
let reader = csv::Reader::new(
file,
- schema.clone(),
+ schema,
has_header,
delimiter,
batch_size,
diff --git a/rust/datafusion/src/physical_plan/empty.rs b/rust/datafusion/src/physical_plan/empty.rs
index 129970fb26..0a7504ba10 100644
--- a/rust/datafusion/src/physical_plan/empty.rs
+++ b/rust/datafusion/src/physical_plan/empty.rs
@@ -139,7 +139,7 @@ mod tests {
#[test]
fn with_new_children() -> Result<()> {
let schema = test::aggr_test_schema();
- let empty = EmptyExec::new(false, schema.clone());
+ let empty = EmptyExec::new(false, schema);
let empty2 = empty.with_new_children(vec![])?;
assert_eq!(empty.schema(), empty2.schema());
@@ -155,7 +155,7 @@ mod tests {
#[tokio::test]
async fn invalid_execute() -> Result<()> {
let schema = test::aggr_test_schema();
- let empty = EmptyExec::new(false, schema.clone());
+ let empty = EmptyExec::new(false, schema);
// ask for the wrong partition
assert!(empty.execute(1).await.is_err());
diff --git a/rust/datafusion/src/physical_plan/expressions.rs b/rust/datafusion/src/physical_plan/expressions.rs
index 8a1e3f004f..4456b67771 100644
--- a/rust/datafusion/src/physical_plan/expressions.rs
+++ b/rust/datafusion/src/physical_plan/expressions.rs
@@ -1334,8 +1334,7 @@ fn common_binary_type(
format!(
"'{:?} {} {:?}' can't be evaluated because there isn't a common type to coerce the types to",
lhs_type, op, rhs_type
- )
- .to_string(),
+ ),
)),
Some(t) => Ok(t)
}
@@ -1602,8 +1601,7 @@ pub fn not(
format!(
"NOT '{:?}' can't be evaluated because the expression's type is {:?}, not boolean",
arg, data_type,
- )
- .to_string(),
+ ),
))
} else {
Ok(Arc::new(NotExpr::new(arg)))
@@ -2279,10 +2277,8 @@ mod tests {
]);
let a = Int32Array::from(vec![1, 2, 3, 4, 5]);
let b = Int32Array::from(vec![1, 2, 4, 8, 16]);
- let batch = RecordBatch::try_new(
- Arc::new(schema.clone()),
- vec![Arc::new(a), Arc::new(b)],
- )?;
+ let batch =
+ RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a), Arc::new(b)])?;
// expression: "a < b"
let lt = binary_simple(col("a"), Operator::Lt, col("b"));
@@ -2309,10 +2305,8 @@ mod tests {
]);
let a = Int32Array::from(vec![2, 4, 6, 8, 10]);
let b = Int32Array::from(vec![2, 5, 4, 8, 8]);
- let batch = RecordBatch::try_new(
- Arc::new(schema.clone()),
- vec![Arc::new(a), Arc::new(b)],
- )?;
+ let batch =
+ RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a), Arc::new(b)])?;
// expression: "a < b OR a == b"
let expr = binary_simple(
@@ -2342,7 +2336,7 @@ mod tests {
// create an arbitrary record bacth
let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]);
let a = Int32Array::from(vec![Some(1), None, Some(3), Some(4), Some(5)]);
- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?;
+ let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)])?;
// create and evaluate a literal expression
let literal_expr = lit(ScalarValue::from(42i32));
@@ -2520,8 +2514,8 @@ mod tests {
StringArray::from(vec![Some("not one"), Some("two"), None, Some("four")]);
let schema = Arc::new(Schema::new(vec![
- Field::new("dict", dict_type.clone(), true),
- Field::new("str", string_type.clone(), true),
+ Field::new("dict", dict_type, true),
+ Field::new("str", string_type, true),
]));
let batch = RecordBatch::try_new(
@@ -2654,7 +2648,7 @@ mod tests {
);
Ok(())
}
-
+ #[allow(clippy::redundant_clone)]
#[test]
fn test_cast_i64_t64() -> Result<()> {
let original = vec![1, 2, 3, 4, 5];
@@ -3208,8 +3202,8 @@ mod tests {
// should handle have negative values in result (for signed)
apply_arithmetic::<Int32Type>(
- schema.clone(),
- vec![b.clone(), a.clone()],
+ schema,
+ vec![b, a],
Operator::Minus,
Int32Array::from(vec![0, 0, -1, -4, -11]),
)?;
@@ -3323,7 +3317,7 @@ mod tests {
fn is_null_op() -> Result<()> {
let schema = Schema::new(vec![Field::new("a", DataType::Utf8, true)]);
let a = StringArray::from(vec![Some("foo"), None]);
- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?;
+ let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)])?;
// expression: "a is null"
let expr = is_null(col("a")).unwrap();
@@ -3344,7 +3338,7 @@ mod tests {
fn is_not_null_op() -> Result<()> {
let schema = Schema::new(vec![Field::new("a", DataType::Utf8, true)]);
let a = StringArray::from(vec![Some("foo"), None]);
- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?;
+ let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)])?;
// expression: "a is not null"
let expr = is_not_null(col("a")).unwrap();
@@ -3488,7 +3482,7 @@ mod tests {
fn case_test_batch() -> Result<RecordBatch> {
let schema = Schema::new(vec![Field::new("a", DataType::Utf8, true)]);
let a = StringArray::from(vec![Some("foo"), Some("baz"), None, Some("bar")]);
- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?;
+ let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)])?;
Ok(batch)
}
}
diff --git a/rust/datafusion/src/physical_plan/filter.rs b/rust/datafusion/src/physical_plan/filter.rs
index 12ba176be5..9324acddb5 100644
--- a/rust/datafusion/src/physical_plan/filter.rs
+++ b/rust/datafusion/src/physical_plan/filter.rs
@@ -54,7 +54,7 @@ impl FilterExec {
) -> Result<Self> {
match predicate.data_type(input.schema().as_ref())? {
DataType::Boolean => Ok(Self {
- predicate: predicate.clone(),
+ predicate,
input: input.clone(),
}),
other => Err(DataFusionError::Plan(format!(
diff --git a/rust/datafusion/src/physical_plan/functions.rs b/rust/datafusion/src/physical_plan/functions.rs
index b63c05d64d..6bcff8a6bf 100644
--- a/rust/datafusion/src/physical_plan/functions.rs
+++ b/rust/datafusion/src/physical_plan/functions.rs
@@ -179,9 +179,10 @@ pub fn return_type(
if arg_types.len() == 0 {
// functions currently cannot be evaluated without arguments, as they can't
// know the number of rows to return.
- return Err(DataFusionError::Plan(
- format!("Function '{}' requires at least one argument", fun).to_string(),
- ));
+ return Err(DataFusionError::Plan(format!(
+ "Function '{}' requires at least one argument",
+ fun
+ )));
}
// the return type of the built in function. Eventually there
@@ -463,7 +464,7 @@ mod tests {
let expr = create_physical_expr(
&BuiltinScalarFunction::Array,
- &vec![lit(value1.clone()), lit(value2.clone())],
+ &vec![lit(value1), lit(value2)],
&schema,
)?;
diff --git a/rust/datafusion/src/physical_plan/hash_aggregate.rs b/rust/datafusion/src/physical_plan/hash_aggregate.rs
index 4dc1f903ff..0c64bc9ea0 100644
--- a/rust/datafusion/src/physical_plan/hash_aggregate.rs
+++ b/rust/datafusion/src/physical_plan/hash_aggregate.rs
@@ -808,7 +808,7 @@ mod tests {
)
.unwrap(),
RecordBatch::try_new(
- schema.clone(),
+ schema,
vec![
Arc::new(UInt32Array::from(vec![2, 3, 3, 4])),
Arc::new(Float64Array::from(vec![1.0, 2.0, 3.0, 4.0])),
diff --git a/rust/datafusion/src/physical_plan/limit.rs b/rust/datafusion/src/physical_plan/limit.rs
index c6b32fb53b..78eb896355 100644
--- a/rust/datafusion/src/physical_plan/limit.rs
+++ b/rust/datafusion/src/physical_plan/limit.rs
@@ -180,7 +180,7 @@ pub fn truncate_batch(batch: &RecordBatch, n: usize) -> RecordBatch {
.map(|i| limit(batch.column(i), n))
.collect();
- RecordBatch::try_new(batch.schema().clone(), limited_columns).unwrap()
+ RecordBatch::try_new(batch.schema(), limited_columns).unwrap()
}
/// A Limit stream limits the stream to up to `limit` rows.
@@ -231,7 +231,7 @@ impl Stream for LimitStream {
impl RecordBatchStream for LimitStream {
/// Get the schema
fn schema(&self) -> SchemaRef {
- self.input.schema().clone()
+ self.input.schema()
}
}
diff --git a/rust/datafusion/src/physical_plan/memory.rs b/rust/datafusion/src/physical_plan/memory.rs
index e7778f9d56..d019c4cc1d 100644
--- a/rust/datafusion/src/physical_plan/memory.rs
+++ b/rust/datafusion/src/physical_plan/memory.rs
@@ -117,8 +117,8 @@ impl MemoryStream {
projection: Option<Vec<usize>>,
) -> Result<Self> {
Ok(Self {
- data: data.clone(),
- schema: schema.clone(),
+ data,
+ schema,
projection,
index: 0,
})
diff --git a/rust/datafusion/src/physical_plan/merge.rs b/rust/datafusion/src/physical_plan/merge.rs
index 8c649b0d34..d0beceb9e4 100644
--- a/rust/datafusion/src/physical_plan/merge.rs
+++ b/rust/datafusion/src/physical_plan/merge.rs
@@ -141,7 +141,7 @@ impl ExecutionPlan for MergeExec {
Ok(Box::pin(MergeStream {
input: receiver,
- schema: self.schema().clone(),
+ schema: self.schema(),
}))
}
}
diff --git a/rust/datafusion/src/physical_plan/parquet.rs b/rust/datafusion/src/physical_plan/parquet.rs
index 07b37c325c..19d2aa3826 100644
--- a/rust/datafusion/src/physical_plan/parquet.rs
+++ b/rust/datafusion/src/physical_plan/parquet.rs
@@ -181,7 +181,7 @@ fn read_file(
let file_reader = Arc::new(SerializedFileReader::new(file)?);
let mut arrow_reader = ParquetFileArrowReader::new(file_reader);
let mut batch_reader =
- arrow_reader.get_record_reader_by_columns(projection.clone(), batch_size)?;
+ arrow_reader.get_record_reader_by_columns(projection, batch_size)?;
loop {
match batch_reader.next() {
Some(Ok(batch)) => send_result(&response_tx, Some(Ok(batch)))?,
diff --git a/rust/datafusion/src/physical_plan/planner.rs b/rust/datafusion/src/physical_plan/planner.rs
index f329971a47..b592111b59 100644
--- a/rust/datafusion/src/physical_plan/planner.rs
+++ b/rust/datafusion/src/physical_plan/planner.rs
@@ -190,7 +190,7 @@ impl DefaultPhysicalPlanner {
)?)),
LogicalPlan::Projection { input, expr, .. } => {
let input = self.create_physical_plan(input, ctx_state)?;
- let input_schema = input.as_ref().schema().clone();
+ let input_schema = input.as_ref().schema();
let runtime_expr = expr
.iter()
.map(|e| {
@@ -210,7 +210,7 @@ impl DefaultPhysicalPlanner {
} => {
// Initially need to perform the aggregate and then merge the partitions
let input = self.create_physical_plan(input, ctx_state)?;
- let input_schema = input.as_ref().schema().clone();
+ let input_schema = input.as_ref().schema();
let groups = group_expr
.iter()
@@ -253,14 +253,14 @@ impl DefaultPhysicalPlanner {
input, predicate, ..
} => {
let input = self.create_physical_plan(input, ctx_state)?;
- let input_schema = input.as_ref().schema().clone();
+ let input_schema = input.as_ref().schema();
let runtime_expr =
self.create_physical_expr(predicate, &input_schema, ctx_state)?;
Ok(Arc::new(FilterExec::try_new(runtime_expr, input)?))
}
LogicalPlan::Sort { expr, input, .. } => {
let input = self.create_physical_plan(input, ctx_state)?;
- let input_schema = input.as_ref().schema().clone();
+ let input_schema = input.as_ref().schema();
let sort_expr = expr
.iter()
diff --git a/rust/datafusion/src/physical_plan/sort.rs b/rust/datafusion/src/physical_plan/sort.rs
index c734e2af78..267fb7d6d6 100644
--- a/rust/datafusion/src/physical_plan/sort.rs
+++ b/rust/datafusion/src/physical_plan/sort.rs
@@ -75,7 +75,7 @@ impl ExecutionPlan for SortExec {
}
fn schema(&self) -> SchemaRef {
- self.input.schema().clone()
+ self.input.schema()
}
fn children(&self) -> Vec<Arc<dyn ExecutionPlan>> {
diff --git a/rust/datafusion/src/physical_plan/udaf.rs b/rust/datafusion/src/physical_plan/udaf.rs
index db86e1447a..a55d2330a3 100644
--- a/rust/datafusion/src/physical_plan/udaf.rs
+++ b/rust/datafusion/src/physical_plan/udaf.rs
@@ -112,7 +112,7 @@ pub fn create_aggregate_expr(
fun: fun.clone(),
args: args.clone(),
data_type: (fun.return_type)(&arg_types)?.as_ref().clone(),
- name: name.clone(),
+ name,
}))
}
diff --git a/rust/datafusion/src/sql/planner.rs b/rust/datafusion/src/sql/planner.rs
index c5007d2230..700260ca70 100644
--- a/rust/datafusion/src/sql/planner.rs
+++ b/rust/datafusion/src/sql/planner.rs
@@ -93,9 +93,10 @@ impl<'a, S: SchemaProvider> SqlToRel<'a, S> {
pub fn query_to_plan(&self, query: &Query) -> Result<LogicalPlan> {
let plan = match &query.body {
SetExpr::Select(s) => self.select_to_plan(s.as_ref()),
- _ => Err(DataFusionError::NotImplemented(
- format!("Query {} not implemented yet", query.body).to_owned(),
- )),
+ _ => Err(DataFusionError::NotImplemented(format!(
+ "Query {} not implemented yet",
+ query.body
+ ))),
}?;
let plan = self.order_by(&plan, &query.order_by)?;
@@ -143,7 +144,7 @@ impl<'a, S: SchemaProvider> SqlToRel<'a, S> {
name: name.clone(),
location: location.clone(),
file_type: file_type.clone(),
- has_header: has_header.clone(),
+ has_header: *has_header,
})
}
@@ -665,10 +666,7 @@ impl<'a, S: SchemaProvider> SqlToRel<'a, S> {
.map(|a| self.sql_to_rex(a, schema))
.collect::<Result<Vec<Expr>>>()?;
- Ok(Expr::ScalarUDF {
- fun: fm.clone(),
- args,
- })
+ Ok(Expr::ScalarUDF { fun: fm, args })
}
None => match self.schema_provider.get_aggregate_meta(&name) {
Some(fm) => {
@@ -678,10 +676,7 @@ impl<'a, S: SchemaProvider> SqlToRel<'a, S> {
.map(|a| self.sql_to_rex(a, schema))
.collect::<Result<Vec<Expr>>>()?;
- Ok(Expr::AggregateUDF {
- fun: fm.clone(),
- args,
- })
+ Ok(Expr::AggregateUDF { fun: fm, args })
}
_ => Err(DataFusionError::Plan(format!(
"Invalid function '{}'",
diff --git a/rust/datafusion/src/test/mod.rs b/rust/datafusion/src/test/mod.rs
index d27cbc4489..99f6c7d8a7 100644
--- a/rust/datafusion/src/test/mod.rs
+++ b/rust/datafusion/src/test/mod.rs
@@ -45,7 +45,7 @@ pub fn create_table_dual() -> Box<dyn TableProvider + Send + Sync> {
],
)
.unwrap();
- let provider = MemTable::new(dual_schema.clone(), vec![vec![batch.clone()]]).unwrap();
+ let provider = MemTable::new(dual_schema, vec![vec![batch]]).unwrap();
Box::new(provider)
}
@@ -262,7 +262,7 @@ pub fn build_table_i32(
]);
RecordBatch::try_new(
- Arc::new(schema.clone()),
+ Arc::new(schema),
vec![
Arc::new(Int32Array::from(a.1.clone())),
Arc::new(Int32Array::from(b.1.clone())),