Apache DataFusion SQL Query Engine
ARROW-10628: [Rust] flag clippy warnings as errors
Andrew Lamb0c1356fe5860
diff --git a/ci/scripts/rust_lint.sh b/ci/scripts/rust_lint.shindex c89988f7af..95ba5e3879 100755--- a/ci/scripts/rust_lint.sh+++ b/ci/scripts/rust_lint.sh@@ -17,10 +17,14 @@# specific language governing permissions and limitations# under the License.+# Entrypoint to run rust linter on CI (automated tests)+#+# Usage: rust_lint.sh <arrow checkout directory>+set -esource_dir=${1}/rustpushd ${source_dir}/arrow- cargo clippy -- -A clippy::redundant_field_names+ cargo clippy --all-targets --workspace -- -D warnings -A clippy::redundant_field_namespopddiff --git a/rust/datafusion/examples/simple_udaf.rs b/rust/datafusion/examples/simple_udaf.rsindex c3cd49fec7..c615653fa3 100644--- a/rust/datafusion/examples/simple_udaf.rs+++ b/rust/datafusion/examples/simple_udaf.rs@@ -163,7 +163,7 @@ async fn main() -> Result<()> {.unwrap();// verify that the calculation is correct- assert_eq!(result.value(0), 8.0);+ assert!((result.value(0) - 8.0).abs() < f64::EPSILON);println!("The geometric mean of [2,4,8,64] is {}", result.value(0));Ok(())diff --git a/rust/datafusion/src/bin/repl.rs b/rust/datafusion/src/bin/repl.rsindex df27f98431..00e42615b9 100644--- a/rust/datafusion/src/bin/repl.rs+++ b/rust/datafusion/src/bin/repl.rs@@ -85,7 +85,7 @@ pub async fn main() {}Ok(ref line) => {query.push_str(line);- query.push_str(" ");+ query.push(' ');}Err(_) => {break;diff --git a/rust/datafusion/tests/dataframe.rs b/rust/datafusion/tests/dataframe.rsindex 3d303ecccd..db31a79f89 100644--- a/rust/datafusion/tests/dataframe.rs+++ b/rust/datafusion/tests/dataframe.rs@@ -164,9 +164,9 @@ async fn custom_source_dataframe() -> Result<()> {assert_eq!(table_schema.fields().len(), 2);assert_eq!(projected_schema.fields().len(), 1);}- _ => assert!(false, "input to projection should be TableScan"),+ _ => panic!("input to projection should be TableScan"),},- _ => assert!(false, "expect optimized_plan to be projection"),+ _ => panic!("expect optimized_plan to be projection"),}let expected = "Projection: #c2\diff --git a/rust/datafusion/tests/sql.rs b/rust/datafusion/tests/sql.rsindex ca8a6cc4f0..f29c4a9f6c 100644--- a/rust/datafusion/tests/sql.rs+++ b/rust/datafusion/tests/sql.rs@@ -82,9 +82,9 @@ async fn nyc() -> Result<()> {assert_eq!(projected_schema.field(0).name(), "passenger_count");assert_eq!(projected_schema.field(1).name(), "fare_amount");}- _ => assert!(false),+ _ => unreachable!(),},- _ => assert!(false),+ _ => unreachable!(false),}Ok(())diff --git a/rust/datafusion/tests/user_defined_plan.rs b/rust/datafusion/tests/user_defined_plan.rsindex ad8e618ad5..b059f5cecb 100644--- a/rust/datafusion/tests/user_defined_plan.rs+++ b/rust/datafusion/tests/user_defined_plan.rs@@ -91,7 +91,7 @@ use async_trait::async_trait;async fn exec_sql(ctx: &mut ExecutionContext, sql: &str) -> Result<String> {let df = ctx.sql(sql)?;let batches = df.collect().await?;- pretty_format_batches(&batches).map_err(|e| DataFusionError::ArrowError(e))+ pretty_format_batches(&batches).map_err(DataFusionError::ArrowError)}/// Create a test table.@@ -494,7 +494,7 @@ impl Stream for TopKReader {// take this as immutablelet k = self.k;- let schema = self.schema().clone();+ let schema = self.schema();let top_values = self.input