From 696b14d5c3952c9d08f7f2a1dc6fb7645bd7f9a3 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sat, 20 Feb 2021 01:49:22 -0800 Subject: [PATCH] ARROW-11708: [Rust] fix Rust 2021 linting warnings --- rust/arrow/src/json/reader.rs | 4 +++- rust/arrow/src/json/writer.rs | 6 +++--- rust/arrow/src/record_batch.rs | 9 +++++---- rust/arrow/src/util/test_util.rs | 4 ++-- rust/datafusion/src/physical_plan/planner.rs | 2 +- .../src/bin/arrow-json-integration-test.rs | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/rust/arrow/src/json/reader.rs b/rust/arrow/src/json/reader.rs index 1b884752be9f..d2cc80cc1f9e 100644 --- a/rust/arrow/src/json/reader.rs +++ b/rust/arrow/src/json/reader.rs @@ -2046,7 +2046,9 @@ mod tests { let read = batch.column(0); assert!( expected.data_ref() == read.data_ref(), - format!("{:?} != {:?}", expected.data(), read.data()) + "{:?} != {:?}", + expected.data(), + read.data(), ); } diff --git a/rust/arrow/src/json/writer.rs b/rust/arrow/src/json/writer.rs index 547e26acff08..bdd29572f58a 100644 --- a/rust/arrow/src/json/writer.rs +++ b/rust/arrow/src/json/writer.rs @@ -156,10 +156,10 @@ pub fn array_to_json_array(array: &ArrayRef) -> Vec { jsonmaps.into_iter().map(Value::Object).collect() } _ => { - panic!(format!( + panic!( "Unsupported datatype for array conversion: {:#?}", array.data_type() - )); + ); } } } @@ -281,7 +281,7 @@ fn set_column_for_json_rows( }); } _ => { - panic!(format!("Unsupported datatype: {:#?}", array.data_type())); + panic!("Unsupported datatype: {:#?}", array.data_type()); } } } diff --git a/rust/arrow/src/record_batch.rs b/rust/arrow/src/record_batch.rs index 00ae4e83a532..2a09c03f814d 100644 --- a/rust/arrow/src/record_batch.rs +++ b/rust/arrow/src/record_batch.rs @@ -278,12 +278,13 @@ impl From<&StructArray> for RecordBatch { } } -impl Into for RecordBatch { - fn into(self) -> StructArray { - self.schema +impl From for StructArray { + fn from(batch: RecordBatch) -> Self { + batch + .schema .fields .iter() - .zip(self.columns.iter()) + .zip(batch.columns.iter()) .map(|t| (t.0.clone(), t.1.clone())) .collect::>() .into() diff --git a/rust/arrow/src/util/test_util.rs b/rust/arrow/src/util/test_util.rs index 8e01d5438d16..b32ff429c9b6 100644 --- a/rust/arrow/src/util/test_util.rs +++ b/rust/arrow/src/util/test_util.rs @@ -78,7 +78,7 @@ pub fn get_temp_file(file_name: &str, content: &[u8]) -> fs::File { pub fn arrow_test_data() -> String { match get_data_dir("ARROW_TEST_DATA", "../../testing/data") { Ok(pb) => pb.display().to_string(), - Err(err) => panic!(format!("failed to get arrow data dir: {}", err)), + Err(err) => panic!("failed to get arrow data dir: {}", err), } } @@ -103,7 +103,7 @@ pub fn parquet_test_data() -> String { "../../cpp/submodules/parquet-testing/data", ) { Ok(pb) => pb.display().to_string(), - Err(err) => panic!(format!("failed to get parquet data dir: {}", err)), + Err(err) => panic!("failed to get parquet data dir: {}", err), } } diff --git a/rust/datafusion/src/physical_plan/planner.rs b/rust/datafusion/src/physical_plan/planner.rs index a2caadedefbc..c83b639c232e 100644 --- a/rust/datafusion/src/physical_plan/planner.rs +++ b/rust/datafusion/src/physical_plan/planner.rs @@ -855,7 +855,7 @@ mod tests { "Expression {:?} expected to error due to impossible coercion", case ); - assert!(logical_plan.is_err(), message); + assert!(logical_plan.is_err(), "{}", message); } Ok(()) } diff --git a/rust/integration-testing/src/bin/arrow-json-integration-test.rs b/rust/integration-testing/src/bin/arrow-json-integration-test.rs index cd89a8edf1d8..52517bc8dc9a 100644 --- a/rust/integration-testing/src/bin/arrow-json-integration-test.rs +++ b/rust/integration-testing/src/bin/arrow-json-integration-test.rs @@ -60,7 +60,7 @@ fn main() -> Result<()> { "JSON_TO_ARROW" => json_to_arrow(json_file, arrow_file, verbose), "ARROW_TO_JSON" => arrow_to_json(arrow_file, json_file, verbose), "VALIDATE" => validate(arrow_file, json_file, verbose), - _ => panic!(format!("mode {} not supported", mode)), + _ => panic!("mode {} not supported", mode), } }