diff --git a/datafusion-examples/examples/avro_sql.rs b/datafusion-examples/examples/avro_sql.rs index 93804c910370..ac1053aa1881 100644 --- a/datafusion-examples/examples/avro_sql.rs +++ b/datafusion-examples/examples/avro_sql.rs @@ -30,7 +30,7 @@ async fn main() -> Result<()> { let testdata = datafusion::test_util::arrow_test_data(); // register avro file with the execution context - let avro_file = &format!("{}/avro/alltypes_plain.avro", testdata); + let avro_file = &format!("{testdata}/avro/alltypes_plain.avro"); ctx.register_avro("alltypes_plain", avro_file, AvroReadOptions::default()) .await?; diff --git a/datafusion/common/src/config.rs b/datafusion/common/src/config.rs index cc85e23367c8..6c61af76a80b 100644 --- a/datafusion/common/src/config.rs +++ b/datafusion/common/src/config.rs @@ -341,8 +341,7 @@ impl ConfigField for ConfigOptions { "optimizer" => self.optimizer.set(rem, value), "explain" => self.explain.set(rem, value), _ => Err(DataFusionError::Internal(format!( - "Config value \"{}\" not found on ConfigOptions", - key + "Config value \"{key}\" not found on ConfigOptions" ))), } } diff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rs index a7a3b93a5886..f27900ad360c 100644 --- a/datafusion/common/src/error.rs +++ b/datafusion/common/src/error.rs @@ -287,7 +287,7 @@ impl Display for DataFusionError { } #[cfg(feature = "avro")] DataFusionError::AvroError(ref desc) => { - write!(f, "Avro error: {}", desc) + write!(f, "Avro error: {desc}") } DataFusionError::IoError(ref desc) => write!(f, "IO error: {desc}"), DataFusionError::SQL(ref desc) => { diff --git a/datafusion/common/src/pyarrow.rs b/datafusion/common/src/pyarrow.rs index f88fd50d3ef7..e8024ab40412 100644 --- a/datafusion/common/src/pyarrow.rs +++ b/datafusion/common/src/pyarrow.rs @@ -94,14 +94,13 @@ mod tests { let python_path: Vec<&str> = locals.get_item("python_path").unwrap().extract().unwrap(); - panic!("pyarrow not found\nExecutable: {}\nPython path: {:?}\n\ + panic!("pyarrow not found\nExecutable: {executable}\nPython path: {python_path:?}\n\ HINT: try `pip install pyarrow`\n\ NOTE: On Mac OS, you must compile against a Framework Python \ (default in python.org installers and brew, but not pyenv)\n\ NOTE: On Mac OS, PYO3 might point to incorrect Python library \ path when using virtual environments. Try \ - `export PYTHONPATH=$(python -c \"import sys; print(sys.path[-1])\")`\n", - executable, python_path) + `export PYTHONPATH=$(python -c \"import sys; print(sys.path[-1])\")`\n") } }) } diff --git a/datafusion/core/src/avro_to_arrow/arrow_array_reader.rs b/datafusion/core/src/avro_to_arrow/arrow_array_reader.rs index 2d6ec2915a68..1f06078e4627 100644 --- a/datafusion/core/src/avro_to_arrow/arrow_array_reader.rs +++ b/datafusion/core/src/avro_to_arrow/arrow_array_reader.rs @@ -97,12 +97,10 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { .map(|value| match value { Ok(Value::Record(v)) => Ok(v), Err(e) => Err(ArrowError::ParseError(format!( - "Failed to parse avro value: {:?}", - e + "Failed to parse avro value: {e:?}" ))), other => Err(ArrowError::ParseError(format!( - "Row needs to be of type object, got: {:?}", - other + "Row needs to be of type object, got: {other:?}" ))), }) .collect::>>>()?; @@ -237,8 +235,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { self.list_array_string_array_builder::(&dtype, col_name, rows) } ref e => Err(SchemaError(format!( - "Data type is currently not supported for dictionaries in list : {:?}", - e + "Data type is currently not supported for dictionaries in list : {e:?}" ))), } } @@ -265,8 +262,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { } e => { return Err(SchemaError(format!( - "Nested list data builder type is not supported: {:?}", - e + "Nested list data builder type is not supported: {e:?}" ))) } }; @@ -331,8 +327,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { } e => { return Err(SchemaError(format!( - "Nested list data builder type is not supported: {:?}", - e + "Nested list data builder type is not supported: {e:?}" ))) } } @@ -564,8 +559,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { } datatype => { return Err(ArrowError::SchemaError(format!( - "Nested list of {:?} not supported", - datatype + "Nested list of {datatype:?} not supported" ))); } }; @@ -673,8 +667,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { ), t => { return Err(ArrowError::SchemaError(format!( - "TimeUnit {:?} not supported with Time64", - t + "TimeUnit {t:?} not supported with Time64" ))) } }, @@ -691,8 +684,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { ), t => { return Err(ArrowError::SchemaError(format!( - "TimeUnit {:?} not supported with Time32", - t + "TimeUnit {t:?} not supported with Time32" ))) } }, @@ -755,7 +747,7 @@ impl<'a, R: Read> AvroArrowArrayReader<'a, R> { bit_util::set_bit(null_buffer.as_slice_mut(), i); value } else { - panic!("expected struct got {:?}", v); + panic!("expected struct got {v:?}"); } }) .collect::>>(); @@ -877,7 +869,7 @@ fn resolve_string(v: &Value) -> ArrowResult { } other => Err(AvroError::GetString(other.into())), } - .map_err(|e| SchemaError(format!("expected resolvable string : {:?}", e))) + .map_err(|e| SchemaError(format!("expected resolvable string : {e:?}"))) } fn resolve_u8(v: &Value) -> AvroResult { @@ -983,7 +975,7 @@ mod test { fn build_reader(name: &str, batch_size: usize) -> Reader { let testdata = crate::test_util::arrow_test_data(); - let filename = format!("{}/avro/{}", testdata, name); + let filename = format!("{testdata}/avro/{name}"); let builder = ReaderBuilder::new() .read_schema() .with_batch_size(batch_size); diff --git a/datafusion/core/src/avro_to_arrow/reader.rs b/datafusion/core/src/avro_to_arrow/reader.rs index d3fc8de96898..a2fa30728527 100644 --- a/datafusion/core/src/avro_to_arrow/reader.rs +++ b/datafusion/core/src/avro_to_arrow/reader.rs @@ -20,7 +20,7 @@ use crate::arrow::datatypes::SchemaRef; use crate::arrow::record_batch::RecordBatch; use crate::error::Result; use arrow::error::Result as ArrowResult; -use std::io::{Read, Seek, SeekFrom}; +use std::io::{Read, Seek}; use std::sync::Arc; /// Avro file reader builder @@ -112,7 +112,7 @@ impl ReaderBuilder { Some(schema) => schema, None => Arc::new(super::read_avro_schema_from_reader(&mut source)?), }; - source.seek(SeekFrom::Start(0))?; + source.rewind()?; Reader::try_new(source, schema, self.batch_size, self.projection) } } @@ -178,7 +178,7 @@ mod tests { fn build_reader(name: &str) -> Reader { let testdata = crate::test_util::arrow_test_data(); - let filename = format!("{}/avro/{}", testdata, name); + let filename = format!("{testdata}/avro/{name}"); let builder = ReaderBuilder::new().read_schema().with_batch_size(64); builder.build(File::open(filename).unwrap()).unwrap() } diff --git a/datafusion/core/src/avro_to_arrow/schema.rs b/datafusion/core/src/avro_to_arrow/schema.rs index b50816f52f96..1af552438e6a 100644 --- a/datafusion/core/src/avro_to_arrow/schema.rs +++ b/datafusion/core/src/avro_to_arrow/schema.rs @@ -424,9 +424,9 @@ mod test { } ] }"#, ); - assert!(schema.is_ok(), "{:?}", schema); + assert!(schema.is_ok(), "{schema:?}"); let arrow_schema = to_arrow_schema(&schema.unwrap()); - assert!(arrow_schema.is_ok(), "{:?}", arrow_schema); + assert!(arrow_schema.is_ok(), "{arrow_schema:?}"); let expected = Schema::new(vec![ Field::new("id", Int32, true), Field::new("bool_col", Boolean, true), @@ -446,7 +446,7 @@ mod test { #[test] fn test_non_record_schema() { let arrow_schema = to_arrow_schema(&AvroSchema::String); - assert!(arrow_schema.is_ok(), "{:?}", arrow_schema); + assert!(arrow_schema.is_ok(), "{arrow_schema:?}"); assert_eq!( arrow_schema.unwrap(), Schema::new(vec![Field::new("", Utf8, false)]) diff --git a/datafusion/core/src/datasource/file_format/avro.rs b/datafusion/core/src/datasource/file_format/avro.rs index 061ebba2fc90..75649c2a309d 100644 --- a/datafusion/core/src/datasource/file_format/avro.rs +++ b/datafusion/core/src/datasource/file_format/avro.rs @@ -215,7 +215,7 @@ mod tests { assert_eq!( "[true, false, true, false, true, false, true, false]", - format!("{:?}", values) + format!("{values:?}") ); Ok(()) @@ -240,7 +240,7 @@ mod tests { values.push(array.value(i)); } - assert_eq!("[4, 5, 6, 7, 2, 3, 0, 1]", format!("{:?}", values)); + assert_eq!("[4, 5, 6, 7, 2, 3, 0, 1]", format!("{values:?}")); Ok(()) } @@ -264,7 +264,7 @@ mod tests { values.push(array.value(i)); } - assert_eq!("[1235865600000000, 1235865660000000, 1238544000000000, 1238544060000000, 1233446400000000, 1233446460000000, 1230768000000000, 1230768060000000]", format!("{:?}", values)); + assert_eq!("[1235865600000000, 1235865660000000, 1238544000000000, 1238544060000000, 1233446400000000, 1233446460000000, 1230768000000000, 1230768060000000]", format!("{values:?}")); Ok(()) } @@ -290,7 +290,7 @@ mod tests { assert_eq!( "[0.0, 1.1, 0.0, 1.1, 0.0, 1.1, 0.0, 1.1]", - format!("{:?}", values) + format!("{values:?}") ); Ok(()) @@ -317,7 +317,7 @@ mod tests { assert_eq!( "[0.0, 10.1, 0.0, 10.1, 0.0, 10.1, 0.0, 10.1]", - format!("{:?}", values) + format!("{values:?}") ); Ok(()) @@ -344,7 +344,7 @@ mod tests { assert_eq!( "[\"0\", \"1\", \"0\", \"1\", \"0\", \"1\", \"0\", \"1\"]", - format!("{:?}", values) + format!("{values:?}") ); Ok(()) @@ -357,7 +357,7 @@ mod tests { limit: Option, ) -> Result> { let testdata = crate::test_util::arrow_test_data(); - let store_root = format!("{}/avro", testdata); + let store_root = format!("{testdata}/avro"); let format = AvroFormat {}; scan_format(state, &format, &store_root, file_name, projection, limit).await } diff --git a/datafusion/core/src/physical_plan/aggregates/row_hash.rs b/datafusion/core/src/physical_plan/aggregates/row_hash.rs index 92f307432eca..994cdd8860a6 100644 --- a/datafusion/core/src/physical_plan/aggregates/row_hash.rs +++ b/datafusion/core/src/physical_plan/aggregates/row_hash.rs @@ -191,7 +191,7 @@ impl GroupedHashAggregateStream { let row_aggr_layout = Arc::new(RowLayout::new(&row_aggr_schema, RowType::WordAligned)); - let name = format!("GroupedHashAggregateStream[{}]", partition); + let name = format!("GroupedHashAggregateStream[{partition}]"); let row_aggr_state = RowAggregationState { reservation: MemoryConsumer::new(name).register(context.memory_pool()), map: RawTable::with_capacity(0), diff --git a/datafusion/core/src/physical_plan/file_format/avro.rs b/datafusion/core/src/physical_plan/file_format/avro.rs index cc797227e3ec..9ac1d23bac83 100644 --- a/datafusion/core/src/physical_plan/file_format/avro.rs +++ b/datafusion/core/src/physical_plan/file_format/avro.rs @@ -251,7 +251,7 @@ mod tests { .register_object_store("file", "", store.clone()); let testdata = crate::test_util::arrow_test_data(); - let filename = format!("{}/avro/alltypes_plain.avro", testdata); + let filename = format!("{testdata}/avro/alltypes_plain.avro"); let meta = local_unpartitioned_file(filename); let file_schema = AvroFormat {} @@ -315,7 +315,7 @@ mod tests { let state = session_ctx.state(); let testdata = crate::test_util::arrow_test_data(); - let filename = format!("{}/avro/alltypes_plain.avro", testdata); + let filename = format!("{testdata}/avro/alltypes_plain.avro"); let object_store = Arc::new(LocalFileSystem::new()) as _; let object_store_url = ObjectStoreUrl::local_filesystem(); let meta = local_unpartitioned_file(filename); @@ -388,7 +388,7 @@ mod tests { let state = session_ctx.state(); let testdata = crate::test_util::arrow_test_data(); - let filename = format!("{}/avro/alltypes_plain.avro", testdata); + let filename = format!("{testdata}/avro/alltypes_plain.avro"); let object_store = Arc::new(LocalFileSystem::new()) as _; let object_store_url = ObjectStoreUrl::local_filesystem(); let meta = local_unpartitioned_file(filename); diff --git a/datafusion/core/src/physical_plan/windows/bounded_window_agg_exec.rs b/datafusion/core/src/physical_plan/windows/bounded_window_agg_exec.rs index 39660742373b..7fc3c638097f 100644 --- a/datafusion/core/src/physical_plan/windows/bounded_window_agg_exec.rs +++ b/datafusion/core/src/physical_plan/windows/bounded_window_agg_exec.rs @@ -697,8 +697,7 @@ fn get_aggregate_result_out_column( } if running_length != len_to_show { return Err(DataFusionError::Execution(format!( - "Generated row number should be {}, it is {}", - len_to_show, running_length + "Generated row number should be {len_to_show}, it is {running_length}" ))); } result diff --git a/datafusion/core/tests/sql/avro.rs b/datafusion/core/tests/sql/avro.rs index 58b318abd874..d7bbf261cddc 100644 --- a/datafusion/core/tests/sql/avro.rs +++ b/datafusion/core/tests/sql/avro.rs @@ -21,7 +21,7 @@ async fn register_alltypes_avro(ctx: &SessionContext) { let testdata = datafusion::test_util::arrow_test_data(); ctx.register_avro( "alltypes_plain", - &format!("{}/avro/alltypes_plain.avro", testdata), + &format!("{testdata}/avro/alltypes_plain.avro"), AvroReadOptions::default(), ) .await @@ -59,7 +59,7 @@ async fn avro_query_multiple_files() { let tempdir = tempfile::tempdir().unwrap(); let table_path = tempdir.path(); let testdata = datafusion::test_util::arrow_test_data(); - let alltypes_plain_file = format!("{}/avro/alltypes_plain.avro", testdata); + let alltypes_plain_file = format!("{testdata}/avro/alltypes_plain.avro"); std::fs::copy( &alltypes_plain_file, format!("{}/alltypes_plain1.avro", table_path.display()), @@ -115,7 +115,7 @@ async fn avro_single_nan_schema() { let testdata = datafusion::test_util::arrow_test_data(); ctx.register_avro( "single_nan", - &format!("{}/avro/single_nan.avro", testdata), + &format!("{testdata}/avro/single_nan.avro"), AvroReadOptions::default(), ) .await diff --git a/datafusion/core/tests/sql/window.rs b/datafusion/core/tests/sql/window.rs index 17cf63b7c88a..22feeed2cb49 100644 --- a/datafusion/core/tests/sql/window.rs +++ b/datafusion/core/tests/sql/window.rs @@ -2426,7 +2426,7 @@ fn write_test_data_to_parquet(tmpdir: &TempDir, n_file: usize) -> Result<()> { )?; let n_chunk = batch.num_rows() / n_file; for i in 0..n_file { - let target_file = tmpdir.path().join(format!("{}.parquet", i)); + let target_file = tmpdir.path().join(format!("{i}.parquet")); let file = File::create(target_file).unwrap(); // Default writer properties let props = WriterProperties::builder().build(); @@ -2516,7 +2516,7 @@ mod tests { LIMIT 5 "; - let msg = format!("Creating logical plan for '{}'", sql); + let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(sql).await.expect(&msg); let physical_plan = dataframe.create_physical_plan().await?; let formatted = displayable(physical_plan.as_ref()).indent().to_string(); @@ -2537,8 +2537,7 @@ mod tests { let actual_trim_last = &actual[..actual_len - 1]; assert_eq!( expected, actual_trim_last, - "\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n", - expected, actual + "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n" ); let actual = execute_to_batches(&ctx, sql).await; @@ -2592,7 +2591,7 @@ mod tests { LIMIT 5 "; - let msg = format!("Creating logical plan for '{}'", sql); + let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(sql).await.expect(&msg); let physical_plan = dataframe.create_physical_plan().await?; let formatted = displayable(physical_plan.as_ref()).indent().to_string(); @@ -2612,8 +2611,7 @@ mod tests { let actual_trim_last = &actual[..actual_len - 1]; assert_eq!( expected, actual_trim_last, - "\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n", - expected, actual + "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n" ); let actual = execute_to_batches(&ctx, sql).await; @@ -2652,7 +2650,7 @@ mod tests { ORDER BY inc_col ASC LIMIT 5"; - let msg = format!("Creating logical plan for '{}'", sql); + let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(sql).await.expect(&msg); let physical_plan = dataframe.create_physical_plan().await?; let formatted = displayable(physical_plan.as_ref()).indent().to_string(); @@ -2672,8 +2670,7 @@ mod tests { let actual_trim_last = &actual[..actual_len - 1]; assert_eq!( expected, actual_trim_last, - "\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n", - expected, actual + "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n" ); let actual = execute_to_batches(&ctx, sql).await; @@ -2707,7 +2704,7 @@ mod tests { ORDER BY inc_col ASC LIMIT 5"; - let msg = format!("Creating logical plan for '{}'", sql); + let msg = format!("Creating logical plan for '{sql}'"); let dataframe = ctx.sql(sql).await.expect(&msg); let physical_plan = dataframe.create_physical_plan().await?; let formatted = displayable(physical_plan.as_ref()).indent().to_string(); @@ -2727,8 +2724,7 @@ mod tests { let actual_trim_last = &actual[..actual_len - 1]; assert_eq!( expected, actual_trim_last, - "\n\nexpected:\n\n{:#?}\nactual:\n\n{:#?}\n\n", - expected, actual + "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n" ); let actual = execute_to_batches(&ctx, sql).await; diff --git a/datafusion/core/tests/sqllogictests/src/engines/postgres/mod.rs b/datafusion/core/tests/sqllogictests/src/engines/postgres/mod.rs index cfefecf69b7f..2d7f02b40848 100644 --- a/datafusion/core/tests/sqllogictests/src/engines/postgres/mod.rs +++ b/datafusion/core/tests/sqllogictests/src/engines/postgres/mod.rs @@ -93,15 +93,15 @@ impl Postgres { // create a new clean schema for running the test debug!("Creating new empty schema '{schema}'"); client - .execute(&format!("DROP SCHEMA IF EXISTS {} CASCADE", schema), &[]) + .execute(&format!("DROP SCHEMA IF EXISTS {schema} CASCADE"), &[]) .await?; client - .execute(&format!("CREATE SCHEMA {}", schema), &[]) + .execute(&format!("CREATE SCHEMA {schema}"), &[]) .await?; client - .execute(&format!("SET search_path TO {}", schema), &[]) + .execute(&format!("SET search_path TO {schema}"), &[]) .await?; Ok(Self { @@ -167,7 +167,7 @@ impl Postgres { // read the input file as a string ans feed it to the copy command let data = std::fs::read_to_string(filename) - .map_err(|e| Error::Copy(format!("Error reading {}: {}", filename, e)))?; + .map_err(|e| Error::Copy(format!("Error reading {filename}: {e}")))?; let mut data_stream = futures::stream::iter(vec![Ok(Bytes::from(data))]).boxed(); @@ -236,7 +236,7 @@ fn cell_to_string(row: &Row, column: &Column, idx: usize) -> String { Type::TIMESTAMP => { let value: Option = row.get(idx); value - .map(|d| format!("{:?}", d)) + .map(|d| format!("{d:?}")) .unwrap_or_else(|| "NULL".to_string()) } Type::BOOL => make_string!(row, idx, bool, bool_to_str), diff --git a/datafusion/core/tests/window_fuzz.rs b/datafusion/core/tests/window_fuzz.rs index d73248bfc2b3..e03758600938 100644 --- a/datafusion/core/tests/window_fuzz.rs +++ b/datafusion/core/tests/window_fuzz.rs @@ -401,9 +401,7 @@ async fn run_window_test( assert_eq!( (i, usual_line), (i, running_line), - "Inconsistent result for window_fn: {:?}, args:{:?}", - window_fn, - args + "Inconsistent result for window_fn: {window_fn:?}, args:{args:?}" ); } } diff --git a/datafusion/optimizer/src/alias.rs b/datafusion/optimizer/src/alias.rs index 70fdeb7ab4e6..6420cc685e25 100644 --- a/datafusion/optimizer/src/alias.rs +++ b/datafusion/optimizer/src/alias.rs @@ -39,6 +39,6 @@ impl AliasGenerator { /// Return a unique alias with the provided prefix pub fn next(&self, prefix: &str) -> String { let id = self.next_id.fetch_add(1, Ordering::Relaxed); - format!("{}_{}", prefix, id) + format!("{prefix}_{id}") } } diff --git a/datafusion/row/src/jit/reader.rs b/datafusion/row/src/jit/reader.rs index 276271a20910..d67035424557 100644 --- a/datafusion/row/src/jit/reader.rs +++ b/datafusion/row/src/jit/reader.rs @@ -113,7 +113,7 @@ fn gen_read_row(schema: &Schema, assembler: &Assembler) -> Result Result Result( +fn write_typed_field_stmt( dt: &DataType, - b: &mut CodeBlock<'a>, + b: &mut CodeBlock, params: Vec, ) -> Result<()> { use DataType::*; diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index f28fb50b4bae..a32b4fe55c02 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -39,8 +39,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { Self::create_placeholder_expr(param, param_data_types) } _ => Err(DataFusionError::Plan(format!( - "Unsupported Value '{:?}'", - value, + "Unsupported Value '{value:?}'", ))), } } diff --git a/datafusion/substrait/src/consumer.rs b/datafusion/substrait/src/consumer.rs index 7293ad9676e9..a650592d5636 100644 --- a/datafusion/substrait/src/consumer.rs +++ b/datafusion/substrait/src/consumer.rs @@ -78,8 +78,7 @@ pub fn name_to_op(name: &str) -> Result { "bitwise_shift_right" => Ok(Operator::BitwiseShiftRight), "bitwise_shift_left" => Ok(Operator::BitwiseShiftLeft), _ => Err(DataFusionError::NotImplemented(format!( - "Unsupported function name: {:?}", - name + "Unsupported function name: {name:?}", ))), } } @@ -99,8 +98,7 @@ pub async fn from_substrait_plan( Ok((ext_f.function_anchor, &ext_f.name)) } _ => Err(DataFusionError::NotImplemented(format!( - "Extension type not supported: {:?}", - ext + "Extension type not supported: {ext:?}", ))), }, None => Err(DataFusionError::NotImplemented( @@ -431,15 +429,13 @@ fn from_substrait_jointype(join_type: i32) -> Result { join_rel::JoinType::Semi => Ok(JoinType::LeftSemi), _ => { return Err(DataFusionError::Internal(format!( - "unsupported join type {:?}", - substrait_join_type + "unsupported join type {substrait_join_type:?}", ))) } } } else { return Err(DataFusionError::Internal(format!( - "invalid join type variant {:?}", - join_type + "invalid join type variant {join_type:?}", ))); } } @@ -601,8 +597,7 @@ pub async fn from_substrait_rex( }))) } (l, r) => Err(DataFusionError::NotImplemented(format!( - "Invalid arguments for binary expression: {:?} and {:?}", - l, r + "Invalid arguments for binary expression: {l:?} and {r:?}", ))), } } @@ -640,14 +635,12 @@ pub async fn from_substrait_rex( ))?; let p = d.precision.try_into().map_err(|e| { DataFusionError::Substrait(format!( - "Failed to parse decimal precision: {}", - e + "Failed to parse decimal precision: {e}", )) })?; let s = d.scale.try_into().map_err(|e| { DataFusionError::Substrait(format!( - "Failed to parse decimal scale: {}", - e + "Failed to parse decimal scale: {e}", )) })?; Ok(Arc::new(Expr::Literal(ScalarValue::Decimal128( diff --git a/datafusion/substrait/src/producer.rs b/datafusion/substrait/src/producer.rs index 163abbaa9aa7..0b05f1dc1488 100644 --- a/datafusion/substrait/src/producer.rs +++ b/datafusion/substrait/src/producer.rs @@ -297,8 +297,7 @@ pub fn to_substrait_rel( to_substrait_rel(alias.input.as_ref(), extension_info) } _ => Err(DataFusionError::NotImplemented(format!( - "Unsupported operator: {:?}", - plan + "Unsupported operator: {plan:?}", ))), } } @@ -383,8 +382,7 @@ pub fn to_substrait_agg_measure( }) }, _ => Err(DataFusionError::Internal(format!( - "Expression must be compatible with aggregation. Unsupported expression: {:?}", - expr + "Expression must be compatible with aggregation. Unsupported expression: {expr:?}", ))), } } @@ -593,8 +591,7 @@ pub fn to_substrait_rex( ScalarValue::Date32(Some(d)) => Some(LiteralType::Date(*d)), _ => { return Err(DataFusionError::NotImplemented(format!( - "Unsupported literal: {:?}", - value + "Unsupported literal: {value:?}", ))) } }; @@ -608,8 +605,7 @@ pub fn to_substrait_rex( } Expr::Alias(expr, _alias) => to_substrait_rex(expr, schema, extension_info), _ => Err(DataFusionError::NotImplemented(format!( - "Unsupported expression: {:?}", - expr + "Unsupported expression: {expr:?}" ))), } } @@ -641,8 +637,7 @@ fn substrait_sort_field( }) } _ => Err(DataFusionError::NotImplemented(format!( - "Expecting sort expression but got {:?}", - expr + "Expecting sort expression but got {expr:?}" ))), } } diff --git a/datafusion/substrait/src/serializer.rs b/datafusion/substrait/src/serializer.rs index 2e09d1c9fa37..e6844edef3a7 100644 --- a/datafusion/substrait/src/serializer.rs +++ b/datafusion/substrait/src/serializer.rs @@ -41,7 +41,7 @@ pub async fn serialize_bytes(sql: &str, ctx: &SessionContext) -> Result> let mut protobuf_out = Vec::::new(); proto.encode(&mut protobuf_out).map_err(|e| { - DataFusionError::Substrait(format!("Failed to encode substrait plan: {}", e)) + DataFusionError::Substrait(format!("Failed to encode substrait plan: {e}")) })?; Ok(protobuf_out) } @@ -57,6 +57,6 @@ pub async fn deserialize(path: &str) -> Result> { pub async fn deserialize_bytes(proto_bytes: Vec) -> Result> { Ok(Box::new(Message::decode(&*proto_bytes).map_err(|e| { - DataFusionError::Substrait(format!("Failed to decode substrait plan: {}", e)) + DataFusionError::Substrait(format!("Failed to decode substrait plan: {e}")) })?)) } diff --git a/datafusion/substrait/tests/roundtrip.rs b/datafusion/substrait/tests/roundtrip.rs index 141f4eb6b17e..fcf01f6c6eca 100644 --- a/datafusion/substrait/tests/roundtrip.rs +++ b/datafusion/substrait/tests/roundtrip.rs @@ -210,7 +210,7 @@ mod tests { let plan = df.into_optimized_plan()?; let proto = to_substrait_plan(&plan)?; let plan2 = from_substrait_plan(&mut ctx, &proto).await?; - let plan2str = format!("{:?}", plan2); + let plan2str = format!("{plan2:?}"); assert_eq!(expected_plan_str, &plan2str); Ok(()) } @@ -223,8 +223,8 @@ mod tests { let plan2 = from_substrait_plan(&mut ctx, &proto).await?; // Format plan string and replace all None's with 0 - let plan1str = format!("{:?}", plan1).replace("None", "0"); - let plan2str = format!("{:?}", plan2).replace("None", "0"); + let plan1str = format!("{plan1:?}").replace("None", "0"); + let plan2str = format!("{plan2:?}").replace("None", "0"); assert_eq!(plan1str, plan2str); Ok(()) @@ -244,11 +244,11 @@ mod tests { let proto = to_substrait_plan(&df.into_optimized_plan()?)?; let plan = from_substrait_plan(&mut ctx, &proto).await?; - println!("{:#?}", plan_with_alias); - println!("{:#?}", plan); + println!("{plan_with_alias:#?}"); + println!("{plan:#?}"); - let plan1str = format!("{:?}", plan_with_alias); - let plan2str = format!("{:?}", plan); + let plan1str = format!("{plan_with_alias:?}"); + let plan2str = format!("{plan:?}"); assert_eq!(plan1str, plan2str); Ok(()) } @@ -262,11 +262,11 @@ mod tests { let plan2 = from_substrait_plan(&mut ctx, &proto).await?; let plan2 = ctx.optimize(&plan2)?; - println!("{:#?}", plan); - println!("{:#?}", plan2); + println!("{plan:#?}"); + println!("{plan2:#?}"); - let plan1str = format!("{:?}", plan); - let plan2str = format!("{:?}", plan2); + let plan1str = format!("{plan:?}"); + let plan2str = format!("{plan2:?}"); assert_eq!(plan1str, plan2str); Ok(()) } diff --git a/datafusion/substrait/tests/serialize.rs b/datafusion/substrait/tests/serialize.rs index 93ac641b00ed..cf70604eb6ca 100644 --- a/datafusion/substrait/tests/serialize.rs +++ b/datafusion/substrait/tests/serialize.rs @@ -43,8 +43,8 @@ mod tests { let plan = from_substrait_plan(&mut ctx, &proto).await?; // #[allow(deprecated)] // let plan = ctx.optimize(&plan)?; - let plan_str_ref = format!("{:?}", plan_ref); - let plan_str = format!("{:?}", plan); + let plan_str_ref = format!("{plan_ref:?}"); + let plan_str = format!("{plan:?}"); assert_eq!(plan_str_ref, plan_str); // Delete test binary file fs::remove_file(path)?;