From a4d41d6a661753f24de0913228f02898ebabc201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= Date: Sun, 4 Aug 2024 19:40:39 +0800 Subject: [PATCH] Support `LogicalPlan` `Debug` differently than `Display` (#11774) * Derive Debug for logical plan nodes * Improve LogicalPlan debug printing * Fix tests * Fix tests * Fix tests --- benchmarks/src/tpch/run.rs | 4 +- datafusion/core/src/dataframe/mod.rs | 14 ++-- .../core/tests/custom_sources_cases/mod.rs | 2 +- .../core/tests/expr_api/simplification.rs | 2 +- .../core/tests/optimizer_integration.rs | 5 +- datafusion/core/tests/sql/explain_analyze.rs | 6 +- .../user_defined/user_defined_aggregates.rs | 2 +- .../user_defined_scalar_functions.rs | 6 +- datafusion/expr/src/logical_plan/builder.rs | 30 ++++---- datafusion/expr/src/logical_plan/ddl.rs | 18 ++--- datafusion/expr/src/logical_plan/dml.rs | 18 ++++- datafusion/expr/src/logical_plan/plan.rs | 17 ++++- datafusion/expr/src/logical_plan/statement.rs | 8 +- .../optimizer/src/common_subexpr_eliminate.rs | 6 +- datafusion/optimizer/src/eliminate_limit.rs | 4 +- .../optimizer/src/optimize_projections/mod.rs | 6 +- datafusion/optimizer/src/push_down_filter.rs | 74 +++++++++---------- .../simplify_expressions/simplify_exprs.rs | 4 +- datafusion/optimizer/src/test/mod.rs | 8 +- .../optimizer/tests/optimizer_integration.rs | 40 +++++----- .../tests/cases/roundtrip_logical_plan.rs | 26 +++---- datafusion/sql/examples/sql.rs | 2 +- datafusion/sql/tests/cases/plan_to_sql.rs | 4 +- datafusion/sql/tests/sql_integration.rs | 11 +-- .../substrait/src/logical_plan/producer.rs | 2 +- .../tests/cases/consumer_integration.rs | 32 ++++---- .../substrait/tests/cases/function_test.rs | 2 +- .../substrait/tests/cases/logical_plans.rs | 6 +- .../tests/cases/roundtrip_logical_plan.rs | 34 ++++----- datafusion/substrait/tests/cases/serialize.rs | 4 +- 30 files changed, 211 insertions(+), 186 deletions(-) diff --git a/benchmarks/src/tpch/run.rs b/benchmarks/src/tpch/run.rs index a72dfaa0f58c..ebc5ac0dbd5a 100644 --- a/benchmarks/src/tpch/run.rs +++ b/benchmarks/src/tpch/run.rs @@ -205,12 +205,12 @@ impl RunOpt { let (state, plan) = plan.into_parts(); if debug { - println!("=== Logical plan ===\n{plan:?}\n"); + println!("=== Logical plan ===\n{plan}\n"); } let plan = state.optimize(&plan)?; if debug { - println!("=== Optimized logical plan ===\n{plan:?}\n"); + println!("=== Optimized logical plan ===\n{plan}\n"); } let physical_plan = state.create_physical_plan(&plan).await?; if debug { diff --git a/datafusion/core/src/dataframe/mod.rs b/datafusion/core/src/dataframe/mod.rs index cacfa4c6f2aa..6ec44b33f89e 100644 --- a/datafusion/core/src/dataframe/mod.rs +++ b/datafusion/core/src/dataframe/mod.rs @@ -2553,7 +2553,7 @@ mod tests { \n TableScan: a\ \n Projection: b.c1, b.c2\ \n TableScan: b"; - assert_eq!(expected_plan, format!("{:?}", join.logical_plan())); + assert_eq!(expected_plan, format!("{}", join.logical_plan())); Ok(()) } @@ -2572,7 +2572,7 @@ mod tests { let expected_plan = "CrossJoin:\ \n TableScan: a projection=[c1], full_filters=[Boolean(NULL)]\ \n TableScan: b projection=[c1]"; - assert_eq!(expected_plan, format!("{:?}", join.into_optimized_plan()?)); + assert_eq!(expected_plan, format!("{}", join.into_optimized_plan()?)); // JOIN ON expression must be boolean type let join = left.join_on(right, JoinType::Inner, Some(lit("TRUE")))?; @@ -2914,7 +2914,7 @@ mod tests { \n Inner Join: t1.c1 = t2.c1\ \n TableScan: t1\ \n TableScan: t2", - format!("{:?}", df_with_column.logical_plan()) + format!("{}", df_with_column.logical_plan()) ); assert_eq!( @@ -2927,7 +2927,7 @@ mod tests { \n TableScan: aggregate_test_100 projection=[c1]\ \n SubqueryAlias: t2\ \n TableScan: aggregate_test_100 projection=[c1]", - format!("{:?}", df_with_column.clone().into_optimized_plan()?) + format!("{}", df_with_column.clone().into_optimized_plan()?) ); let df_results = df_with_column.collect().await?; @@ -3109,7 +3109,7 @@ mod tests { \n Inner Join: t1.c1 = t2.c1\ \n TableScan: t1\ \n TableScan: t2", - format!("{:?}", df_renamed.logical_plan()) + format!("{}", df_renamed.logical_plan()) ); assert_eq!("\ @@ -3121,7 +3121,7 @@ mod tests { \n TableScan: aggregate_test_100 projection=[c1, c2, c3]\ \n SubqueryAlias: t2\ \n TableScan: aggregate_test_100 projection=[c1, c2, c3]", - format!("{:?}", df_renamed.clone().into_optimized_plan()?) + format!("{}", df_renamed.clone().into_optimized_plan()?) ); let df_results = df_renamed.collect().await?; @@ -3306,7 +3306,7 @@ mod tests { assert_eq!( "TableScan: ?table? projection=[c2, c3, sum]", - format!("{:?}", cached_df.clone().into_optimized_plan()?) + format!("{}", cached_df.clone().into_optimized_plan()?) ); let df_results = df.collect().await?; diff --git a/datafusion/core/tests/custom_sources_cases/mod.rs b/datafusion/core/tests/custom_sources_cases/mod.rs index 7c051ffaa7e1..673fafe55b53 100644 --- a/datafusion/core/tests/custom_sources_cases/mod.rs +++ b/datafusion/core/tests/custom_sources_cases/mod.rs @@ -246,7 +246,7 @@ async fn custom_source_dataframe() -> Result<()> { } let expected = format!("TableScan: {UNNAMED_TABLE} projection=[c2]"); - assert_eq!(format!("{optimized_plan:?}"), expected); + assert_eq!(format!("{optimized_plan}"), expected); let physical_plan = state.create_physical_plan(&optimized_plan).await?; diff --git a/datafusion/core/tests/expr_api/simplification.rs b/datafusion/core/tests/expr_api/simplification.rs index 9ce47153ba4a..b6068e4859df 100644 --- a/datafusion/core/tests/expr_api/simplification.rs +++ b/datafusion/core/tests/expr_api/simplification.rs @@ -119,7 +119,7 @@ fn get_optimized_plan_formatted(plan: LogicalPlan, date_time: &DateTime) -> let optimizer = Optimizer::with_rules(vec![Arc::new(SimplifyExpressions::new())]); let optimized_plan = optimizer.optimize(plan, &config, observe).unwrap(); - format!("{optimized_plan:?}") + format!("{optimized_plan}") } // ------------------------------ diff --git a/datafusion/core/tests/optimizer_integration.rs b/datafusion/core/tests/optimizer_integration.rs index 39f745cd3309..f17d13a42060 100644 --- a/datafusion/core/tests/optimizer_integration.rs +++ b/datafusion/core/tests/optimizer_integration.rs @@ -81,14 +81,13 @@ fn timestamp_nano_ts_utc_predicates() { let sql = "SELECT col_int32 FROM test WHERE col_ts_nano_utc < (now() - interval '1 hour')"; - let plan = test_sql(sql).unwrap(); // a scan should have the now()... predicate folded to a single // constant and compared to the column without a cast so it can be // pushed down / pruned let expected = "Projection: test.col_int32\n Filter: test.col_ts_nano_utc < TimestampNanosecond(1666612093000000000, Some(\"+00:00\"))\ \n TableScan: test projection=[col_int32, col_ts_nano_utc]"; - assert_eq!(expected, format!("{plan:?}")); + quick_test(sql, expected); } #[test] @@ -117,7 +116,7 @@ fn concat_ws_literals() -> Result<()> { fn quick_test(sql: &str, expected_plan: &str) { let plan = test_sql(sql).unwrap(); - assert_eq!(expected_plan, format!("{:?}", plan)); + assert_eq!(expected_plan, format!("{}", plan)); } fn test_sql(sql: &str) -> Result { diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs index fe4777b04396..07be00fc3515 100644 --- a/datafusion/core/tests/sql/explain_analyze.rs +++ b/datafusion/core/tests/sql/explain_analyze.rs @@ -253,7 +253,7 @@ async fn csv_explain_plans() { // Optimized logical plan let state = ctx.state(); - let msg = format!("Optimizing logical plan for '{sql}': {plan:?}"); + let msg = format!("Optimizing logical plan for '{sql}': {plan}"); let plan = state.optimize(plan).expect(&msg); let optimized_logical_schema = plan.schema(); // Both schema has to be the same @@ -327,7 +327,7 @@ async fn csv_explain_plans() { // Physical plan // Create plan - let msg = format!("Creating physical plan for '{sql}': {plan:?}"); + let msg = format!("Creating physical plan for '{sql}': {plan}"); let plan = state.create_physical_plan(&plan).await.expect(&msg); // // Execute plan @@ -548,7 +548,7 @@ async fn csv_explain_verbose_plans() { // Physical plan // Create plan - let msg = format!("Creating physical plan for '{sql}': {plan:?}"); + let msg = format!("Creating physical plan for '{sql}': {plan}"); let plan = state.create_physical_plan(&plan).await.expect(&msg); // // Execute plan diff --git a/datafusion/core/tests/user_defined/user_defined_aggregates.rs b/datafusion/core/tests/user_defined/user_defined_aggregates.rs index 96de865b6554..93550d38021a 100644 --- a/datafusion/core/tests/user_defined/user_defined_aggregates.rs +++ b/datafusion/core/tests/user_defined/user_defined_aggregates.rs @@ -413,7 +413,7 @@ async fn test_parameterized_aggregate_udf() -> Result<()> { .build()?; assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Aggregate: groupBy=[[t.text]], aggr=[[geo_mean(t.text) AS a, geo_mean(t.text) AS b]]\n TableScan: t projection=[text]" ); diff --git a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs index 9164e89de8f9..259cce74f2e5 100644 --- a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs @@ -139,7 +139,7 @@ async fn scalar_udf() -> Result<()> { .build()?; assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Projection: t.a, t.b, my_add(t.a, t.b)\n TableScan: t projection=[a, b]" ); @@ -393,7 +393,7 @@ async fn udaf_as_window_func() -> Result<()> { TableScan: my_table"#; let dataframe = context.sql(sql).await.unwrap(); - assert_eq!(format!("{:?}", dataframe.logical_plan()), expected); + assert_eq!(format!("{}", dataframe.logical_plan()), expected); Ok(()) } @@ -1124,7 +1124,7 @@ async fn test_parameterized_scalar_udf() -> Result<()> { .build()?; assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: t.text IS NOT NULL\n Filter: regex_udf(t.text) AND regex_udf(t.text)\n TableScan: t projection=[text]" ); diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs index 736310c7ac0f..aa2ea4ae1c26 100644 --- a/datafusion/expr/src/logical_plan/builder.rs +++ b/datafusion/expr/src/logical_plan/builder.rs @@ -1749,7 +1749,7 @@ mod tests { \n Filter: employee_csv.state = Utf8(\"CO\")\ \n TableScan: employee_csv projection=[id, state]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1802,7 +1802,7 @@ mod tests { let expected = "Sort: employee_csv.state ASC NULLS FIRST, employee_csv.salary DESC NULLS LAST\ \n TableScan: employee_csv projection=[state, salary]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1822,7 +1822,7 @@ mod tests { \n TableScan: t1\ \n TableScan: t2"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1847,7 +1847,7 @@ mod tests { \n TableScan: employee_csv projection=[state, salary]\ \n TableScan: employee_csv projection=[state, salary]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1876,7 +1876,7 @@ mod tests { \n TableScan: employee_csv projection=[state, salary]\ \n TableScan: employee_csv projection=[state, salary]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1913,7 +1913,7 @@ mod tests { \n Filter: employee_csv.state = Utf8(\"CO\")\ \n TableScan: employee_csv projection=[id, state]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -1940,7 +1940,7 @@ mod tests { \n TableScan: foo\ \n Projection: bar.a\ \n TableScan: bar"; - assert_eq!(expected, format!("{outer_query:?}")); + assert_eq!(expected, format!("{outer_query}")); Ok(()) } @@ -1968,7 +1968,7 @@ mod tests { \n TableScan: foo\ \n Projection: bar.a\ \n TableScan: bar"; - assert_eq!(expected, format!("{outer_query:?}")); + assert_eq!(expected, format!("{outer_query}")); Ok(()) } @@ -1994,7 +1994,7 @@ mod tests { \n Projection: foo.b\ \n TableScan: foo\ \n TableScan: bar"; - assert_eq!(expected, format!("{outer_query:?}")); + assert_eq!(expected, format!("{outer_query}")); Ok(()) } @@ -2116,7 +2116,7 @@ mod tests { let expected = "\ Unnest: lists[test_table.strings] structs[]\ \n TableScan: test_table"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); // Check unnested field is a scalar let field = plan.schema().field_with_name(None, "strings").unwrap(); @@ -2130,7 +2130,7 @@ mod tests { let expected = "\ Unnest: lists[] structs[test_table.struct_singular]\ \n TableScan: test_table"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); for field_name in &["a", "b"] { // Check unnested struct field is a scalar @@ -2153,7 +2153,7 @@ mod tests { \n Unnest: lists[test_table.structs] structs[]\ \n Unnest: lists[test_table.strings] structs[]\ \n TableScan: test_table"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); // Check unnested struct list field should be a struct. let field = plan.schema().field_with_name(None, "structs").unwrap(); @@ -2171,7 +2171,7 @@ mod tests { let expected = "\ Unnest: lists[test_table.strings, test_table.structs] structs[test_table.struct_singular]\ \n TableScan: test_table"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); // Unnesting missing column should fail. let plan = nested_table_scan("test_table")?.unnest_column("missing"); @@ -2263,9 +2263,9 @@ mod tests { ])? .build()?; - let plan_expected = format!("{plan:?}"); + let plan_expected = format!("{plan}"); let plan_builder: LogicalPlanBuilder = Arc::new(plan).into(); - assert_eq!(plan_expected, format!("{:?}", plan_builder.plan)); + assert_eq!(plan_expected, format!("{}", plan_builder.plan)); Ok(()) } diff --git a/datafusion/expr/src/logical_plan/ddl.rs b/datafusion/expr/src/logical_plan/ddl.rs index 45ddbafecfd7..255bf4699b7f 100644 --- a/datafusion/expr/src/logical_plan/ddl.rs +++ b/datafusion/expr/src/logical_plan/ddl.rs @@ -29,7 +29,7 @@ use datafusion_common::{Constraints, DFSchemaRef, SchemaReference, TableReferenc use sqlparser::ast::Ident; /// Various types of DDL (CREATE / DROP) catalog manipulation -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DdlStatement { /// Creates an external table. CreateExternalTable(CreateExternalTable), @@ -179,7 +179,7 @@ impl DdlStatement { } /// Creates an external table. -#[derive(Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CreateExternalTable { /// The table schema pub schema: DFSchemaRef, @@ -224,7 +224,7 @@ impl Hash for CreateExternalTable { } /// Creates an in memory table. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CreateMemoryTable { /// The table name pub name: TableReference, @@ -241,7 +241,7 @@ pub struct CreateMemoryTable { } /// Creates a view. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CreateView { /// The table name pub name: TableReference, @@ -254,7 +254,7 @@ pub struct CreateView { } /// Creates a catalog (aka "Database"). -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CreateCatalog { /// The catalog name pub catalog_name: String, @@ -265,7 +265,7 @@ pub struct CreateCatalog { } /// Creates a schema. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CreateCatalogSchema { /// The table schema pub schema_name: String, @@ -276,7 +276,7 @@ pub struct CreateCatalogSchema { } /// Drops a table. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DropTable { /// The table name pub name: TableReference, @@ -287,7 +287,7 @@ pub struct DropTable { } /// Drops a view. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DropView { /// The view name pub name: TableReference, @@ -298,7 +298,7 @@ pub struct DropView { } /// Drops a schema -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DropCatalogSchema { /// The schema name pub name: SchemaReference, diff --git a/datafusion/expr/src/logical_plan/dml.rs b/datafusion/expr/src/logical_plan/dml.rs index c9eef9bd34cc..025bb7b289dc 100644 --- a/datafusion/expr/src/logical_plan/dml.rs +++ b/datafusion/expr/src/logical_plan/dml.rs @@ -16,7 +16,7 @@ // under the License. use std::collections::HashMap; -use std::fmt::{self, Display}; +use std::fmt::{self, Debug, Display, Formatter}; use std::hash::{Hash, Hasher}; use std::sync::Arc; @@ -41,6 +41,18 @@ pub struct CopyTo { pub options: HashMap, } +impl Debug for CopyTo { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("CopyTo") + .field("input", &self.input) + .field("output_url", &self.output_url) + .field("partition_by", &self.partition_by) + .field("file_type", &"...") + .field("options", &self.options) + .finish_non_exhaustive() + } +} + // Implement PartialEq manually impl PartialEq for CopyTo { fn eq(&self, other: &Self) -> bool { @@ -61,7 +73,7 @@ impl Hash for CopyTo { /// The operator that modifies the content of a database (adapted from /// substrait WriteRel) -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DmlStatement { /// The table name pub table_name: TableReference, @@ -100,7 +112,7 @@ impl DmlStatement { } } -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum WriteOp { InsertOverwrite, InsertInto, diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 6bea1ad948a1..02176a506a25 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -187,7 +187,7 @@ pub use datafusion_common::{JoinConstraint, JoinType}; /// # } /// ``` /// -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum LogicalPlan { /// Evaluates an arbitrary list of expressions (essentially a /// SELECT with an expression list) on its input. @@ -1882,7 +1882,7 @@ impl LogicalPlan { } } -impl Debug for LogicalPlan { +impl Display for LogicalPlan { fn fmt(&self, f: &mut Formatter) -> fmt::Result { self.display_indent().fmt(f) } @@ -2291,6 +2291,19 @@ pub struct TableScan { pub fetch: Option, } +impl Debug for TableScan { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + f.debug_struct("TableScan") + .field("table_name", &self.table_name) + .field("source", &"...") + .field("projection", &self.projection) + .field("projected_schema", &self.projected_schema) + .field("filters", &self.filters) + .field("fetch", &self.fetch) + .finish_non_exhaustive() + } +} + impl PartialEq for TableScan { fn eq(&self, other: &Self) -> bool { self.table_name == other.table_name diff --git a/datafusion/expr/src/logical_plan/statement.rs b/datafusion/expr/src/logical_plan/statement.rs index f294e7d3ea4c..21ff8dbd8eec 100644 --- a/datafusion/expr/src/logical_plan/statement.rs +++ b/datafusion/expr/src/logical_plan/statement.rs @@ -25,7 +25,7 @@ use std::fmt::{self, Display}; /// While DataFusion does not offer support transactions, it provides /// [`LogicalPlan`](crate::LogicalPlan) support to assist building /// database systems using DataFusion -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Statement { // Begin a transaction TransactionStart(TransactionStart), @@ -115,7 +115,7 @@ pub enum TransactionIsolationLevel { } /// Indicator that the following statements should be committed or rolled back atomically -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TransactionStart { /// indicates if transaction is allowed to write pub access_mode: TransactionAccessMode, @@ -126,7 +126,7 @@ pub struct TransactionStart { } /// Indicator that any current transaction should be terminated -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TransactionEnd { /// whether the transaction committed or aborted pub conclusion: TransactionConclusion, @@ -138,7 +138,7 @@ pub struct TransactionEnd { /// Set a Variable's value -- value in /// [`ConfigOptions`](datafusion_common::config::ConfigOptions) -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SetVariable { /// The variable name pub variable: String, diff --git a/datafusion/optimizer/src/common_subexpr_eliminate.rs b/datafusion/optimizer/src/common_subexpr_eliminate.rs index 70ca6f5304ad..9cd9e4dece26 100644 --- a/datafusion/optimizer/src/common_subexpr_eliminate.rs +++ b/datafusion/optimizer/src/common_subexpr_eliminate.rs @@ -1189,7 +1189,7 @@ mod test { plan: LogicalPlan, config: Option<&dyn OptimizerConfig>, ) { - assert_eq!(expected, format!("{plan:?}"), "Unexpected starting plan"); + assert_eq!(expected, format!("{plan}"), "Unexpected starting plan"); let optimizer = CommonSubexprEliminate::new(); let default_config = OptimizerContext::new(); let config = config.unwrap_or(&default_config); @@ -1198,7 +1198,7 @@ mod test { let optimized_plan = optimized_plan.data; assert_eq!( expected, - format!("{optimized_plan:?}"), + format!("{optimized_plan}"), "Unexpected optimized plan" ); } @@ -1214,7 +1214,7 @@ mod test { let optimized_plan = optimizer.rewrite(plan, config).unwrap(); assert!(optimized_plan.transformed, "failed to optimize plan"); let optimized_plan = optimized_plan.data; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(expected, formatted_plan); } diff --git a/datafusion/optimizer/src/eliminate_limit.rs b/datafusion/optimizer/src/eliminate_limit.rs index 165834e75975..a42fe6a6f95b 100644 --- a/datafusion/optimizer/src/eliminate_limit.rs +++ b/datafusion/optimizer/src/eliminate_limit.rs @@ -105,7 +105,7 @@ mod tests { let optimized_plan = optimizer.optimize(plan, &OptimizerContext::new(), observe)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); Ok(()) } @@ -123,7 +123,7 @@ mod tests { let optimized_plan = optimizer .optimize(plan, &config, observe) .expect("failed to optimize plan"); - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); Ok(()) } diff --git a/datafusion/optimizer/src/optimize_projections/mod.rs b/datafusion/optimizer/src/optimize_projections/mod.rs index 31d59da13323..a307d0ae0a0b 100644 --- a/datafusion/optimizer/src/optimize_projections/mod.rs +++ b/datafusion/optimizer/src/optimize_projections/mod.rs @@ -1529,7 +1529,7 @@ mod tests { \n TableScan: test2 projection=[c1]"; let optimized_plan = optimize(plan)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); // make sure schema for join node include both join columns @@ -1581,7 +1581,7 @@ mod tests { \n TableScan: test2 projection=[c1]"; let optimized_plan = optimize(plan)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); // make sure schema for join node include both join columns @@ -1631,7 +1631,7 @@ mod tests { \n TableScan: test2 projection=[a]"; let optimized_plan = optimize(plan)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); // make sure schema for join node include both join columns diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs index f9c9ec961c8e..4254d3464662 100644 --- a/datafusion/optimizer/src/push_down_filter.rs +++ b/datafusion/optimizer/src/push_down_filter.rs @@ -1240,7 +1240,7 @@ mod tests { let optimized_plan = optimizer.optimize(plan, &OptimizerContext::new(), observe)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(expected, formatted_plan); Ok(()) } @@ -1401,7 +1401,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "\ Filter: b = Int64(1)\ \n Projection: test.a * Int32(2) + test.c AS b, test.c\ @@ -1431,7 +1431,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "\ Filter: a = Int64(1)\ \n Projection: b * Int32(3) AS a, test.c\ @@ -1581,7 +1581,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "\ Filter: sum(test.c) > Int64(10)\ \n Filter: b > Int64(10)\ @@ -1616,7 +1616,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "\ Filter: sum(test.c) > Int64(10) AND b > Int64(10) AND sum(test.c) < Int64(20)\ \n Aggregate: groupBy=[[b]], aggr=[[sum(test.c)]]\ @@ -1765,7 +1765,7 @@ mod tests { // not part of the test assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.a >= Int64(1)\ \n Projection: test.a\ \n Limit: skip=0, fetch=1\ @@ -1797,7 +1797,7 @@ mod tests { // not part of the test assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Projection: test.a\ \n Filter: test.a >= Int64(1)\ \n Filter: test.a <= Int64(1)\ @@ -1831,7 +1831,7 @@ mod tests { \n TableScan: test"; // not part of the test - assert_eq!(format!("{plan:?}"), expected); + assert_eq!(format!("{plan}"), expected); let expected = "\ TestUserDefined\ @@ -1861,7 +1861,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.a <= Int64(1)\ \n Inner Join: test.a = test2.a\ \n TableScan: test\ @@ -1898,7 +1898,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.a <= Int64(1)\ \n Inner Join: Using test.a = test2.a\ \n TableScan: test\ @@ -1938,7 +1938,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.c <= test2.b\ \n Inner Join: test.a = test2.a\ \n Projection: test.a, test.c\ @@ -1981,7 +1981,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.b <= Int64(1)\ \n Inner Join: test.a = test2.a\ \n Projection: test.a, test.b\ @@ -2020,7 +2020,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test2.a <= Int64(1)\ \n Left Join: Using test.a = test2.a\ \n TableScan: test\ @@ -2058,7 +2058,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.a <= Int64(1)\ \n Right Join: Using test.a = test2.a\ \n TableScan: test\ @@ -2097,7 +2097,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test.a <= Int64(1)\ \n Left Join: Using test.a = test2.a\ \n TableScan: test\ @@ -2135,7 +2135,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: test2.a <= Int64(1)\ \n Right Join: Using test.a = test2.a\ \n TableScan: test\ @@ -2178,7 +2178,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Inner Join: test.a = test2.a Filter: test.c > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4)\ \n Projection: test.a, test.b, test.c\ \n TableScan: test\ @@ -2220,7 +2220,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Inner Join: test.a = test2.a Filter: test.b > UInt32(1) AND test2.c > UInt32(4)\ \n Projection: test.a, test.b, test.c\ \n TableScan: test\ @@ -2260,7 +2260,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Inner Join: test.a = test2.b Filter: test.a > UInt32(1)\ \n Projection: test.a\ \n TableScan: test\ @@ -2303,7 +2303,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Left Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4)\ \n Projection: test.a, test.b, test.c\ \n TableScan: test\ @@ -2346,7 +2346,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Right Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4)\ \n Projection: test.a, test.b, test.c\ \n TableScan: test\ @@ -2389,7 +2389,7 @@ mod tests { // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Full Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4)\ \n Projection: test.a, test.b, test.c\ \n TableScan: test\ @@ -2397,7 +2397,7 @@ mod tests { \n TableScan: test2" ); - let expected = &format!("{plan:?}"); + let expected = &format!("{plan}"); assert_optimized_plan_eq(plan, expected) } @@ -2574,7 +2574,7 @@ Projection: a, b // filter on col b assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: b > Int64(10) AND test.c > Int64(10)\ \n Projection: test.a AS b, test.c\ \n TableScan: test" @@ -2603,7 +2603,7 @@ Projection: a, b // filter on col b assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: b > Int64(10) AND test.c > Int64(10)\ \n Projection: b, test.c\ \n Projection: test.a AS b, test.c\ @@ -2631,7 +2631,7 @@ Projection: a, b // filter on col b and d assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: b > Int64(10) AND d > Int64(10)\ \n Projection: test.a AS b, test.c AS d\ \n TableScan: test\ @@ -2668,7 +2668,7 @@ Projection: a, b .build()?; assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Inner Join: c = d Filter: c > UInt32(1)\ \n Projection: test.a AS c\ \n TableScan: test\ @@ -2700,7 +2700,7 @@ Projection: a, b // filter on col b assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: b IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ \n Projection: test.a AS b, test.c\ \n TableScan: test\ @@ -2730,7 +2730,7 @@ Projection: a, b // filter on col b assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "Filter: b IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ \n Projection: b, test.c\ \n Projection: test.a AS b, test.c\ @@ -2771,7 +2771,7 @@ Projection: a, b \n TableScan: sq\ \n Projection: test.a AS b, test.c\ \n TableScan: test"; - assert_eq!(format!("{plan:?}"), expected_before); + assert_eq!(format!("{plan}"), expected_before); // rewrite filter col b to test.a let expected_after = "\ @@ -2802,7 +2802,7 @@ Projection: a, b \n SubqueryAlias: b\ \n Projection: Int64(0) AS a\ \n EmptyRelation"; - assert_eq!(format!("{plan:?}"), expected_before); + assert_eq!(format!("{plan}"), expected_before); // Ensure that the predicate without any columns (0 = 1) is // still there. @@ -2877,7 +2877,7 @@ Projection: a, b // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "LeftSemi Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2)\ \n TableScan: test1\ \n Projection: test2.a, test2.b\ @@ -2918,7 +2918,7 @@ Projection: a, b // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "RightSemi Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2)\ \n TableScan: test1\ \n Projection: test2.a, test2.b\ @@ -2962,7 +2962,7 @@ Projection: a, b // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "LeftAnti Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2)\ \n Projection: test1.a, test1.b\ \n TableScan: test1\ @@ -3008,7 +3008,7 @@ Projection: a, b // not part of the test, just good to know: assert_eq!( - format!("{plan:?}"), + format!("{plan}"), "RightAnti Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2)\ \n Projection: test1.a, test1.b\ \n TableScan: test1\ @@ -3074,7 +3074,7 @@ Projection: a, b \n Projection: test1.a, sum(test1.b), TestScalarUDF() + Int32(1) AS r\ \n Aggregate: groupBy=[[test1.a]], aggr=[[sum(test1.b)]]\ \n TableScan: test1"; - assert_eq!(format!("{plan:?}"), expected_before); + assert_eq!(format!("{plan}"), expected_before); let expected_after = "Projection: t.a, t.r\ \n SubqueryAlias: t\ @@ -3119,7 +3119,7 @@ Projection: a, b \n Inner Join: test1.a = test2.a\ \n TableScan: test1\ \n TableScan: test2"; - assert_eq!(format!("{plan:?}"), expected_before); + assert_eq!(format!("{plan}"), expected_before); let expected = "Projection: t.a, t.r\ \n SubqueryAlias: t\ diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs index e44f60d1df22..cb9ec3024d93 100644 --- a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs +++ b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs @@ -187,7 +187,7 @@ mod tests { let optimizer = Optimizer::with_rules(vec![Arc::new(SimplifyExpressions::new())]); let optimized_plan = optimizer.optimize(plan, &OptimizerContext::new(), observe)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); Ok(()) } @@ -437,7 +437,7 @@ mod tests { let rule = SimplifyExpressions::new(); let optimized_plan = rule.rewrite(plan, &config).unwrap().data; - format!("{optimized_plan:?}") + format!("{optimized_plan}") } #[test] diff --git a/datafusion/optimizer/src/test/mod.rs b/datafusion/optimizer/src/test/mod.rs index 4dccb42941dd..1266b548ab05 100644 --- a/datafusion/optimizer/src/test/mod.rs +++ b/datafusion/optimizer/src/test/mod.rs @@ -116,7 +116,7 @@ pub fn assert_analyzed_plan_eq( let options = ConfigOptions::default(); let analyzed_plan = Analyzer::with_rules(vec![rule]).execute_and_check(plan, &options, |_, _| {})?; - let formatted_plan = format!("{analyzed_plan:?}"); + let formatted_plan = format!("{analyzed_plan}"); assert_eq!(formatted_plan, expected); Ok(()) @@ -130,7 +130,7 @@ pub fn assert_analyzed_plan_ne( let options = ConfigOptions::default(); let analyzed_plan = Analyzer::with_rules(vec![rule]).execute_and_check(plan, &options, |_, _| {})?; - let formatted_plan = format!("{analyzed_plan:?}"); + let formatted_plan = format!("{analyzed_plan}"); assert_ne!(formatted_plan, expected); Ok(()) @@ -178,7 +178,7 @@ pub fn assert_optimized_plan_eq( let optimizer = Optimizer::with_rules(vec![Arc::clone(&rule)]); let optimized_plan = optimizer.optimize(plan, &opt_context, observe)?; - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); assert_eq!(formatted_plan, expected); Ok(()) @@ -205,7 +205,7 @@ pub fn assert_optimized_plan_with_rules( eq: bool, ) -> Result<()> { let optimized_plan = generate_optimized_plan_with_rules(rules, plan); - let formatted_plan = format!("{optimized_plan:?}"); + let formatted_plan = format!("{optimized_plan}"); if eq { assert_eq!(formatted_plan, expected); } else { diff --git a/datafusion/optimizer/tests/optimizer_integration.rs b/datafusion/optimizer/tests/optimizer_integration.rs index 3c77ffaa17f6..aaa5eec3955c 100644 --- a/datafusion/optimizer/tests/optimizer_integration.rs +++ b/datafusion/optimizer/tests/optimizer_integration.rs @@ -50,13 +50,13 @@ fn case_when() -> Result<()> { let expected = "Projection: CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END AS CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); let sql = "SELECT CASE WHEN col_uint32 > 0 THEN 1 ELSE 0 END FROM test"; let plan = test_sql(sql)?; let expected = "Projection: CASE WHEN test.col_uint32 > UInt32(0) THEN Int64(1) ELSE Int64(0) END AS CASE WHEN test.col_uint32 > Int64(0) THEN Int64(1) ELSE Int64(0) END\ \n TableScan: test projection=[col_uint32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -78,7 +78,7 @@ fn subquery_filter_with_cast() -> Result<()> { \n Projection: test.col_int32\ \n Filter: test.col_utf8 >= Utf8(\"2002-05-08\") AND test.col_utf8 <= Utf8(\"2002-05-13\")\ \n TableScan: test projection=[col_int32, col_utf8]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -89,7 +89,7 @@ fn case_when_aggregate() -> Result<()> { let expected = "Projection: test.col_utf8, sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END) AS n\ \n Aggregate: groupBy=[[test.col_utf8]], aggr=[[sum(CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END) AS sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END)]]\ \n TableScan: test projection=[col_int32, col_utf8]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -100,7 +100,7 @@ fn unsigned_target_type() -> Result<()> { let expected = "Projection: test.col_utf8\ \n Filter: test.col_uint32 > UInt32(0)\ \n TableScan: test projection=[col_uint32, col_utf8]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -111,7 +111,7 @@ fn distribute_by() -> Result<()> { let plan = test_sql(sql)?; let expected = "Repartition: DistributeBy(test.col_utf8)\ \n TableScan: test projection=[col_int32, col_utf8]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -128,7 +128,7 @@ fn semi_join_with_join_filter() -> Result<()> { \n SubqueryAlias: __correlated_sq_1\ \n SubqueryAlias: t2\ \n TableScan: test projection=[col_int32, col_uint32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -145,7 +145,7 @@ fn anti_join_with_join_filter() -> Result<()> { \n SubqueryAlias: __correlated_sq_1\ \n SubqueryAlias: t2\ \n TableScan: test projection=[col_int32, col_uint32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -160,7 +160,7 @@ fn where_exists_distinct() -> Result<()> { \n Aggregate: groupBy=[[t2.col_int32]], aggr=[[]]\ \n SubqueryAlias: t2\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -178,7 +178,7 @@ fn intersect() -> Result<()> { \n TableScan: test projection=[col_int32, col_utf8]\ \n TableScan: test projection=[col_int32, col_utf8]\ \n TableScan: test projection=[col_int32, col_utf8]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -192,7 +192,7 @@ fn between_date32_plus_interval() -> Result<()> { \n Projection: \ \n Filter: test.col_date32 >= Date32(\"1998-03-18\") AND test.col_date32 <= Date32(\"1998-06-16\")\ \n TableScan: test projection=[col_date32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -206,7 +206,7 @@ fn between_date64_plus_interval() -> Result<()> { \n Projection: \ \n Filter: test.col_date64 >= Date64(\"1998-03-18\") AND test.col_date64 <= Date64(\"1998-06-16\")\ \n TableScan: test projection=[col_date64]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); Ok(()) } @@ -216,7 +216,7 @@ fn propagate_empty_relation() { let plan = test_sql(sql).unwrap(); // when children exist EmptyRelation, it will bottom-up propagate. let expected = "EmptyRelation"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -232,7 +232,7 @@ fn join_keys_in_subquery_alias() { \n Filter: test.col_int32 IS NOT NULL\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -251,7 +251,7 @@ fn join_keys_in_subquery_alias_1() { \n SubqueryAlias: c\ \n Filter: test.col_int32 IS NOT NULL\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -262,7 +262,7 @@ fn push_down_filter_groupby_expr_contains_alias() { \n Aggregate: groupBy=[[test.col_int32 + CAST(test.col_uint32 AS Int32)]], aggr=[[count(Int64(1)) AS count(*)]]\ \n Filter: test.col_int32 + CAST(test.col_uint32 AS Int32) > Int32(3)\ \n TableScan: test projection=[col_int32, col_uint32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -276,7 +276,7 @@ fn test_same_name_but_not_ambiguous() { \n TableScan: test projection=[col_int32]\ \n SubqueryAlias: t2\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -291,7 +291,7 @@ fn eliminate_nested_filters() { Filter: test.col_int32 > Int32(0)\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -306,7 +306,7 @@ fn eliminate_redundant_null_check_on_count() { Projection: test.col_int32, count(*) AS c\ \n Aggregate: groupBy=[[test.col_int32]], aggr=[[count(Int64(1)) AS count(*)]]\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } #[test] @@ -332,7 +332,7 @@ fn test_propagate_empty_relation_inner_join_and_unions() { \n TableScan: test projection=[col_int32]\ \n Filter: test.col_int32 < Int32(0)\ \n TableScan: test projection=[col_int32]"; - assert_eq!(expected, format!("{plan:?}")); + assert_eq!(expected, format!("{plan}")); } fn test_sql(sql: &str) -> Result { diff --git a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs b/datafusion/proto/tests/cases/roundtrip_logical_plan.rs index d150c474e88f..b96398ef217f 100644 --- a/datafusion/proto/tests/cases/roundtrip_logical_plan.rs +++ b/datafusion/proto/tests/cases/roundtrip_logical_plan.rs @@ -308,7 +308,7 @@ async fn roundtrip_logical_plan_aggregation_with_pk() -> Result<()> { let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -334,7 +334,7 @@ async fn roundtrip_logical_plan_aggregation() -> Result<()> { let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -358,7 +358,7 @@ async fn roundtrip_logical_plan_copy_to_sql_options() -> Result<()> { let bytes = logical_plan_to_bytes_with_extension_codec(&plan, &codec)?; let logical_round_trip = logical_plan_from_bytes_with_extension_codec(&bytes, &ctx, &codec)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -430,7 +430,7 @@ async fn roundtrip_logical_plan_copy_to_arrow() -> Result<()> { let bytes = logical_plan_to_bytes_with_extension_codec(&plan, &codec)?; let logical_round_trip = logical_plan_from_bytes_with_extension_codec(&bytes, &ctx, &codec)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); match logical_round_trip { LogicalPlan::Copy(copy_to) => { @@ -544,7 +544,7 @@ async fn roundtrip_logical_plan_copy_to_json() -> Result<()> { let bytes = logical_plan_to_bytes_with_extension_codec(&plan, &codec)?; let logical_round_trip = logical_plan_from_bytes_with_extension_codec(&bytes, &ctx, &codec)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); match logical_round_trip { LogicalPlan::Copy(copy_to) => { @@ -614,7 +614,7 @@ async fn roundtrip_logical_plan_copy_to_parquet() -> Result<()> { let bytes = logical_plan_to_bytes_with_extension_codec(&plan, &codec)?; let logical_round_trip = logical_plan_from_bytes_with_extension_codec(&bytes, &ctx, &codec)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); match logical_round_trip { LogicalPlan::Copy(copy_to) => { @@ -701,7 +701,7 @@ async fn roundtrip_logical_plan_distinct_on() -> Result<()> { let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -727,7 +727,7 @@ async fn roundtrip_single_count_distinct() -> Result<()> { let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -740,7 +740,7 @@ async fn roundtrip_logical_plan_with_extension() -> Result<()> { let plan = ctx.table("t1").await?.into_optimized_plan()?; let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -765,7 +765,7 @@ async fn roundtrip_logical_plan_unnest() -> Result<()> { let plan = ctx.sql(query).await?.into_optimized_plan()?; let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -906,7 +906,7 @@ async fn roundtrip_expr_api() -> Result<()> { let plan = table.select(expr_list)?.into_optimized_plan()?; let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } @@ -926,13 +926,13 @@ async fn roundtrip_logical_plan_with_view_scan() -> Result<()> { let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); // DROP let plan = ctx.sql("DROP VIEW view_t1").await?.into_optimized_plan()?; let bytes = logical_plan_to_bytes(&plan)?; let logical_round_trip = logical_plan_from_bytes(&bytes, &ctx)?; - assert_eq!(format!("{plan:?}"), format!("{logical_round_trip:?}")); + assert_eq!(format!("{plan}"), format!("{logical_round_trip}")); Ok(()) } diff --git a/datafusion/sql/examples/sql.rs b/datafusion/sql/examples/sql.rs index d9ee1b4db8e2..aa17be6273ae 100644 --- a/datafusion/sql/examples/sql.rs +++ b/datafusion/sql/examples/sql.rs @@ -63,7 +63,7 @@ fn main() { let plan = sql_to_rel.sql_statement_to_plan(statement.clone()).unwrap(); // show the plan - println!("{plan:?}"); + println!("{plan}"); } struct MyContextProvider { diff --git a/datafusion/sql/tests/cases/plan_to_sql.rs b/datafusion/sql/tests/cases/plan_to_sql.rs index bae3ec2e2779..b65f976a2251 100644 --- a/datafusion/sql/tests/cases/plan_to_sql.rs +++ b/datafusion/sql/tests/cases/plan_to_sql.rs @@ -209,7 +209,7 @@ fn roundtrip_crossjoin() -> Result<()> { \n TableScan: j1\ \n TableScan: j2"; - assert_eq!(format!("{plan_roundtrip:?}"), expected); + assert_eq!(format!("{plan_roundtrip}"), expected); Ok(()) } @@ -420,7 +420,7 @@ fn test_unnest_logical_plan() -> Result<()> { \n Projection: unnest_table.struct_col AS unnest(unnest_table.struct_col), unnest_table.array_col AS unnest(unnest_table.array_col), unnest_table.struct_col, unnest_table.array_col\ \n TableScan: unnest_table"; - assert_eq!(format!("{plan:?}"), expected); + assert_eq!(format!("{plan}"), expected); Ok(()) } diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index c1b2246e4980..e61c29f1c80d 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -149,7 +149,8 @@ fn parse_ident_normalization() { }, ); if plan.is_ok() { - assert_eq!(expected, format!("{plan:?}")); + let plan = plan.unwrap(); + assert_eq!(expected, format!("Ok({plan})")); } else { assert_eq!(expected, plan.unwrap_err().strip_backtrace()); } @@ -198,7 +199,7 @@ fn test_parse_options_value_normalization() { }, ); if let Ok(plan) = plan { - assert_eq!(expected_plan, format!("{plan:?}")); + assert_eq!(expected_plan, format!("{plan}")); match plan { LogicalPlan::Ddl(DdlStatement::CreateExternalTable( @@ -2827,7 +2828,7 @@ fn quick_test(sql: &str, expected: &str) { fn quick_test_with_options(sql: &str, expected: &str, options: ParserOptions) { let plan = logical_plan_with_options(sql, options).unwrap(); - assert_eq!(format!("{plan:?}"), expected); + assert_eq!(format!("{plan}"), expected); } fn prepare_stmt_quick_test( @@ -2839,7 +2840,7 @@ fn prepare_stmt_quick_test( let assert_plan = plan.clone(); // verify plan - assert_eq!(format!("{assert_plan:?}"), expected_plan); + assert_eq!(format!("{assert_plan}"), expected_plan); // verify data types if let LogicalPlan::Prepare(Prepare { data_types, .. }) = assert_plan { @@ -2857,7 +2858,7 @@ fn prepare_stmt_replace_params_quick_test( ) -> LogicalPlan { // replace params let plan = plan.with_param_values(param_values).unwrap(); - assert_eq!(format!("{plan:?}"), expected_plan); + assert_eq!(format!("{plan}"), expected_plan); plan } diff --git a/datafusion/substrait/src/logical_plan/producer.rs b/datafusion/substrait/src/logical_plan/producer.rs index bd6e0e00491a..a782af8eb247 100644 --- a/datafusion/substrait/src/logical_plan/producer.rs +++ b/datafusion/substrait/src/logical_plan/producer.rs @@ -558,7 +558,7 @@ pub fn to_substrait_rel( rel_type: Some(rel_type), })) } - _ => not_impl_err!("Unsupported operator: {plan:?}"), + _ => not_impl_err!("Unsupported operator: {plan}"), } } diff --git a/datafusion/substrait/tests/cases/consumer_integration.rs b/datafusion/substrait/tests/cases/consumer_integration.rs index 8fbcd721166e..fc5f82127d05 100644 --- a/datafusion/substrait/tests/cases/consumer_integration.rs +++ b/datafusion/substrait/tests/cases/consumer_integration.rs @@ -55,7 +55,7 @@ mod tests { let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!( plan_str, "Projection: FILENAME_PLACEHOLDER_0.l_returnflag AS L_RETURNFLAG, FILENAME_PLACEHOLDER_0.l_linestatus AS L_LINESTATUS, sum(FILENAME_PLACEHOLDER_0.l_quantity) AS SUM_QTY, sum(FILENAME_PLACEHOLDER_0.l_extendedprice) AS SUM_BASE_PRICE, sum(FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount) AS SUM_DISC_PRICE, sum(FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount * Int32(1) + FILENAME_PLACEHOLDER_0.l_tax) AS SUM_CHARGE, avg(FILENAME_PLACEHOLDER_0.l_quantity) AS AVG_QTY, avg(FILENAME_PLACEHOLDER_0.l_extendedprice) AS AVG_PRICE, avg(FILENAME_PLACEHOLDER_0.l_discount) AS AVG_DISC, count(Int64(1)) AS COUNT_ORDER\ @@ -89,7 +89,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!( plan_str, "Projection: FILENAME_PLACEHOLDER_1.s_acctbal AS S_ACCTBAL, FILENAME_PLACEHOLDER_1.s_name AS S_NAME, FILENAME_PLACEHOLDER_3.n_name AS N_NAME, FILENAME_PLACEHOLDER_0.p_partkey AS P_PARTKEY, FILENAME_PLACEHOLDER_0.p_mfgr AS P_MFGR, FILENAME_PLACEHOLDER_1.s_address AS S_ADDRESS, FILENAME_PLACEHOLDER_1.s_phone AS S_PHONE, FILENAME_PLACEHOLDER_1.s_comment AS S_COMMENT\ @@ -136,7 +136,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_2.l_orderkey AS L_ORDERKEY, sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) AS REVENUE, FILENAME_PLACEHOLDER_1.o_orderdate AS O_ORDERDATE, FILENAME_PLACEHOLDER_1.o_shippriority AS O_SHIPPRIORITY\ \n Limit: skip=0, fetch=10\ \n Sort: sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) DESC NULLS FIRST, FILENAME_PLACEHOLDER_1.o_orderdate ASC NULLS LAST\ @@ -164,7 +164,7 @@ mod tests { )) .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.o_orderpriority AS O_ORDERPRIORITY, count(Int64(1)) AS ORDER_COUNT\ \n Sort: FILENAME_PLACEHOLDER_0.o_orderpriority ASC NULLS LAST\ \n Aggregate: groupBy=[[FILENAME_PLACEHOLDER_0.o_orderpriority]], aggr=[[count(Int64(1))]]\ @@ -195,7 +195,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: NATION.n_name AS N_NAME, sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) AS REVENUE\ \n Sort: sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) DESC NULLS FIRST\ \n Aggregate: groupBy=[[NATION.n_name]], aggr=[[sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount)]]\ @@ -229,7 +229,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Aggregate: groupBy=[[]], aggr=[[sum(FILENAME_PLACEHOLDER_0.l_extendedprice * FILENAME_PLACEHOLDER_0.l_discount) AS REVENUE]]\ \n Projection: FILENAME_PLACEHOLDER_0.l_extendedprice * FILENAME_PLACEHOLDER_0.l_discount\ \n Filter: FILENAME_PLACEHOLDER_0.l_shipdate >= CAST(Utf8(\"1994-01-01\") AS Date32) AND FILENAME_PLACEHOLDER_0.l_shipdate < CAST(Utf8(\"1995-01-01\") AS Date32) AND FILENAME_PLACEHOLDER_0.l_discount >= Decimal128(Some(5),3,2) AND FILENAME_PLACEHOLDER_0.l_discount <= Decimal128(Some(7),3,2) AND FILENAME_PLACEHOLDER_0.l_quantity < CAST(Int32(24) AS Decimal128(19, 0))\ @@ -254,7 +254,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.c_custkey AS C_CUSTKEY, FILENAME_PLACEHOLDER_0.c_name AS C_NAME, sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) AS REVENUE, FILENAME_PLACEHOLDER_0.c_acctbal AS C_ACCTBAL, FILENAME_PLACEHOLDER_3.n_name AS N_NAME, FILENAME_PLACEHOLDER_0.c_address AS C_ADDRESS, FILENAME_PLACEHOLDER_0.c_phone AS C_PHONE, FILENAME_PLACEHOLDER_0.c_comment AS C_COMMENT\ \n Limit: skip=0, fetch=20\ \n Sort: sum(FILENAME_PLACEHOLDER_2.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_2.l_discount) DESC NULLS FIRST\ @@ -289,7 +289,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.ps_partkey AS PS_PARTKEY, sum(FILENAME_PLACEHOLDER_0.ps_supplycost * FILENAME_PLACEHOLDER_0.ps_availqty) AS value\ \n Sort: sum(FILENAME_PLACEHOLDER_0.ps_supplycost * FILENAME_PLACEHOLDER_0.ps_availqty) DESC NULLS FIRST\ \n Filter: sum(FILENAME_PLACEHOLDER_0.ps_supplycost * FILENAME_PLACEHOLDER_0.ps_availqty) > ()\ @@ -329,7 +329,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: count(FILENAME_PLACEHOLDER_1.o_orderkey) AS C_COUNT, count(Int64(1)) AS CUSTDIST\ \n Sort: count(Int64(1)) DESC NULLS FIRST, count(FILENAME_PLACEHOLDER_1.o_orderkey) DESC NULLS FIRST\ \n Projection: count(FILENAME_PLACEHOLDER_1.o_orderkey), count(Int64(1))\ @@ -357,7 +357,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: Decimal128(Some(10000),5,2) * sum(CASE WHEN FILENAME_PLACEHOLDER_1.p_type LIKE CAST(Utf8(\"PROMO%\") AS Utf8) THEN FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount ELSE Decimal128(Some(0),19,0) END) / sum(FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount) AS PROMO_REVENUE\ \n Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN FILENAME_PLACEHOLDER_1.p_type LIKE CAST(Utf8(\"PROMO%\") AS Utf8) THEN FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount ELSE Decimal128(Some(0),19,0) END), sum(FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount)]]\ \n Projection: CASE WHEN FILENAME_PLACEHOLDER_1.p_type LIKE CAST(Utf8(\"PROMO%\") AS Utf8) THEN FILENAME_PLACEHOLDER_0.l_extendedprice * (CAST(Int32(1) AS Decimal128(19, 0)) - FILENAME_PLACEHOLDER_0.l_discount) ELSE Decimal128(Some(0),19,0) END, FILENAME_PLACEHOLDER_0.l_extendedprice * (CAST(Int32(1) AS Decimal128(19, 0)) - FILENAME_PLACEHOLDER_0.l_discount)\ @@ -383,7 +383,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_1.p_brand AS P_BRAND, FILENAME_PLACEHOLDER_1.p_type AS P_TYPE, FILENAME_PLACEHOLDER_1.p_size AS P_SIZE, count(DISTINCT FILENAME_PLACEHOLDER_0.ps_suppkey) AS SUPPLIER_CNT\ \n Sort: count(DISTINCT FILENAME_PLACEHOLDER_0.ps_suppkey) DESC NULLS FIRST, FILENAME_PLACEHOLDER_1.p_brand ASC NULLS LAST, FILENAME_PLACEHOLDER_1.p_type ASC NULLS LAST, FILENAME_PLACEHOLDER_1.p_size ASC NULLS LAST\ \n Aggregate: groupBy=[[FILENAME_PLACEHOLDER_1.p_brand, FILENAME_PLACEHOLDER_1.p_type, FILENAME_PLACEHOLDER_1.p_size]], aggr=[[count(DISTINCT FILENAME_PLACEHOLDER_0.ps_suppkey)]]\ @@ -434,7 +434,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.c_name AS C_NAME, FILENAME_PLACEHOLDER_0.c_custkey AS C_CUSTKEY, FILENAME_PLACEHOLDER_1.o_orderkey AS O_ORDERKEY, FILENAME_PLACEHOLDER_1.o_orderdate AS O_ORDERDATE, FILENAME_PLACEHOLDER_1.o_totalprice AS O_TOTALPRICE, sum(FILENAME_PLACEHOLDER_2.l_quantity) AS EXPR$5\ \n Limit: skip=0, fetch=100\ \n Sort: FILENAME_PLACEHOLDER_1.o_totalprice DESC NULLS FIRST, FILENAME_PLACEHOLDER_1.o_orderdate ASC NULLS LAST\ @@ -468,7 +468,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Aggregate: groupBy=[[]], aggr=[[sum(FILENAME_PLACEHOLDER_0.l_extendedprice * Int32(1) - FILENAME_PLACEHOLDER_0.l_discount) AS REVENUE]]\n Projection: FILENAME_PLACEHOLDER_0.l_extendedprice * (CAST(Int32(1) AS Decimal128(19, 0)) - FILENAME_PLACEHOLDER_0.l_discount)\ \n Filter: FILENAME_PLACEHOLDER_1.p_partkey = FILENAME_PLACEHOLDER_0.l_partkey AND FILENAME_PLACEHOLDER_1.p_brand = CAST(Utf8(\"Brand#12\") AS Utf8) AND (FILENAME_PLACEHOLDER_1.p_container = Utf8(\"SM CASE\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"SM BOX\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"SM PACK\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"SM PKG\")) AND FILENAME_PLACEHOLDER_0.l_quantity >= CAST(Int32(1) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_0.l_quantity <= CAST(Int32(1) + Int32(10) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_1.p_size >= Int32(1) AND FILENAME_PLACEHOLDER_1.p_size <= Int32(5) AND (FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR\") OR FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR REG\")) AND FILENAME_PLACEHOLDER_0.l_shipinstruct = CAST(Utf8(\"DELIVER IN PERSON\") AS Utf8) OR FILENAME_PLACEHOLDER_1.p_partkey = FILENAME_PLACEHOLDER_0.l_partkey AND FILENAME_PLACEHOLDER_1.p_brand = CAST(Utf8(\"Brand#23\") AS Utf8) AND (FILENAME_PLACEHOLDER_1.p_container = Utf8(\"MED BAG\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"MED BOX\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"MED PKG\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"MED PACK\")) AND FILENAME_PLACEHOLDER_0.l_quantity >= CAST(Int32(10) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_0.l_quantity <= CAST(Int32(10) + Int32(10) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_1.p_size >= Int32(1) AND FILENAME_PLACEHOLDER_1.p_size <= Int32(10) AND (FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR\") OR FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR REG\")) AND FILENAME_PLACEHOLDER_0.l_shipinstruct = CAST(Utf8(\"DELIVER IN PERSON\") AS Utf8) OR FILENAME_PLACEHOLDER_1.p_partkey = FILENAME_PLACEHOLDER_0.l_partkey AND FILENAME_PLACEHOLDER_1.p_brand = CAST(Utf8(\"Brand#34\") AS Utf8) AND (FILENAME_PLACEHOLDER_1.p_container = Utf8(\"LG CASE\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"LG BOX\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"LG PACK\") OR FILENAME_PLACEHOLDER_1.p_container = Utf8(\"LG PKG\")) AND FILENAME_PLACEHOLDER_0.l_quantity >= CAST(Int32(20) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_0.l_quantity <= CAST(Int32(20) + Int32(10) AS Decimal128(19, 0)) AND FILENAME_PLACEHOLDER_1.p_size >= Int32(1) AND FILENAME_PLACEHOLDER_1.p_size <= Int32(15) AND (FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR\") OR FILENAME_PLACEHOLDER_0.l_shipmode = Utf8(\"AIR REG\")) AND FILENAME_PLACEHOLDER_0.l_shipinstruct = CAST(Utf8(\"DELIVER IN PERSON\") AS Utf8)\ \n Inner Join: Filter: Boolean(true)\ @@ -494,7 +494,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.s_name AS S_NAME, FILENAME_PLACEHOLDER_0.s_address AS S_ADDRESS\ \n Sort: FILENAME_PLACEHOLDER_0.s_name ASC NULLS LAST\ \n Projection: FILENAME_PLACEHOLDER_0.s_name, FILENAME_PLACEHOLDER_0.s_address\ @@ -537,7 +537,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: FILENAME_PLACEHOLDER_0.s_name AS S_NAME, count(Int64(1)) AS NUMWAIT\ \n Limit: skip=0, fetch=100\ \n Sort: count(Int64(1)) DESC NULLS FIRST, FILENAME_PLACEHOLDER_0.s_name ASC NULLS LAST\ @@ -574,7 +574,7 @@ mod tests { .expect("failed to parse json"); let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!(plan_str, "Projection: substr(FILENAME_PLACEHOLDER_0.c_phone,Int32(1),Int32(2)) AS CNTRYCODE, count(Int64(1)) AS NUMCUST, sum(FILENAME_PLACEHOLDER_0.c_acctbal) AS TOTACCTBAL\n Sort: substr(FILENAME_PLACEHOLDER_0.c_phone,Int32(1),Int32(2)) ASC NULLS LAST\ \n Aggregate: groupBy=[[substr(FILENAME_PLACEHOLDER_0.c_phone,Int32(1),Int32(2))]], aggr=[[count(Int64(1)), sum(FILENAME_PLACEHOLDER_0.c_acctbal)]]\ \n Projection: substr(FILENAME_PLACEHOLDER_0.c_phone, Int32(1), Int32(2)), FILENAME_PLACEHOLDER_0.c_acctbal\ diff --git a/datafusion/substrait/tests/cases/function_test.rs b/datafusion/substrait/tests/cases/function_test.rs index b4c5659a3a49..610caf3a81df 100644 --- a/datafusion/substrait/tests/cases/function_test.rs +++ b/datafusion/substrait/tests/cases/function_test.rs @@ -38,7 +38,7 @@ mod tests { let plan = from_substrait_plan(&ctx, &proto).await?; - let plan_str = format!("{:?}", plan); + let plan_str = format!("{}", plan); assert_eq!( plan_str, diff --git a/datafusion/substrait/tests/cases/logical_plans.rs b/datafusion/substrait/tests/cases/logical_plans.rs index 6492febc938e..f6a2b5036c80 100644 --- a/datafusion/substrait/tests/cases/logical_plans.rs +++ b/datafusion/substrait/tests/cases/logical_plans.rs @@ -44,7 +44,7 @@ mod tests { let plan = from_substrait_plan(&ctx, &proto).await?; assert_eq!( - format!("{:?}", plan), + format!("{}", plan), "Projection: NOT DATA.a AS EXPR$0\ \n TableScan: DATA projection=[a, b, c, d, e, f]" ); @@ -70,7 +70,7 @@ mod tests { let plan = from_substrait_plan(&ctx, &proto).await?; assert_eq!( - format!("{:?}", plan), + format!("{}", plan), "Projection: sum(DATA.a) PARTITION BY [DATA.b] ORDER BY [DATA.c ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING AS LEAD_EXPR\ \n WindowAggr: windowExpr=[[sum(DATA.a) PARTITION BY [DATA.b] ORDER BY [DATA.c ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING]]\ \n TableScan: DATA projection=[a, b, c, d, e, f]" @@ -89,7 +89,7 @@ mod tests { let plan = from_substrait_plan(&ctx, &proto).await?; - assert_eq!(format!("{:?}", &plan), "Values: (List([1, 2]))"); + assert_eq!(format!("{}", &plan), "Values: (List([1, 2]))"); // Need to trigger execution to ensure that Arrow has validated the plan DataFrame::new(ctx.state(), plan).show().await?; diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs index 439e3efa2922..083a589fce26 100644 --- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs +++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs @@ -841,8 +841,8 @@ async fn extension_logical_plan() -> Result<()> { let proto = to_substrait_plan(&ext_plan, &ctx)?; let plan2 = from_substrait_plan(&ctx, &proto).await?; - let plan1str = format!("{ext_plan:?}"); - let plan2str = format!("{plan2:?}"); + let plan1str = format!("{ext_plan}"); + let plan2str = format!("{plan2}"); assert_eq!(plan1str, plan2str); Ok(()) @@ -943,7 +943,7 @@ async fn roundtrip_repartition_roundrobin() -> Result<()> { let plan2 = from_substrait_plan(&ctx, &proto).await?; let plan2 = ctx.state().optimize(&plan2)?; - assert_eq!(format!("{plan:?}"), format!("{plan2:?}")); + assert_eq!(format!("{plan}"), format!("{plan2}")); Ok(()) } @@ -960,7 +960,7 @@ async fn roundtrip_repartition_hash() -> Result<()> { let plan2 = from_substrait_plan(&ctx, &proto).await?; let plan2 = ctx.state().optimize(&plan2)?; - assert_eq!(format!("{plan:?}"), format!("{plan2:?}")); + assert_eq!(format!("{plan}"), format!("{plan2}")); Ok(()) } @@ -1061,8 +1061,8 @@ async fn assert_expected_plan( let plan2 = from_substrait_plan(&ctx, &proto).await?; let plan2 = ctx.state().optimize(&plan2)?; - println!("{plan:#?}"); - println!("{plan2:#?}"); + println!("{plan}"); + println!("{plan2}"); println!("{proto:?}"); @@ -1070,7 +1070,7 @@ async fn assert_expected_plan( assert_eq!(plan.schema(), plan2.schema()); } - let plan2str = format!("{plan2:?}"); + let plan2str = format!("{plan2}"); assert_eq!(expected_plan_str, &plan2str); Ok(()) @@ -1085,8 +1085,8 @@ async fn roundtrip_fill_na(sql: &str) -> Result<()> { let plan2 = ctx.state().optimize(&plan2)?; // Format plan string and replace all None's with 0 - let plan1str = format!("{plan:?}").replace("None", "0"); - let plan2str = format!("{plan2:?}").replace("None", "0"); + let plan1str = format!("{plan}").replace("None", "0"); + let plan2str = format!("{plan2}").replace("None", "0"); assert_eq!(plan1str, plan2str); @@ -1108,11 +1108,11 @@ async fn test_alias(sql_with_alias: &str, sql_no_alias: &str) -> Result<()> { let proto = to_substrait_plan(&df.into_optimized_plan()?, &ctx)?; let plan = from_substrait_plan(&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); assert_eq!(plan_with_alias.schema(), plan.schema()); @@ -1126,13 +1126,13 @@ async fn roundtrip_with_ctx(sql: &str, ctx: SessionContext) -> Result> let plan2 = from_substrait_plan(&ctx, &proto).await?; let plan2 = ctx.state().optimize(&plan2)?; - println!("{plan:#?}"); - println!("{plan2:#?}"); + println!("{plan}"); + println!("{plan2}"); println!("{proto:?}"); - let plan1str = format!("{plan:?}"); - let plan2str = format!("{plan2:?}"); + let plan1str = format!("{plan}"); + let plan2str = format!("{plan2}"); assert_eq!(plan1str, plan2str); assert_eq!(plan.schema(), plan2.schema()); diff --git a/datafusion/substrait/tests/cases/serialize.rs b/datafusion/substrait/tests/cases/serialize.rs index f6736ca22279..d792ac33c333 100644 --- a/datafusion/substrait/tests/cases/serialize.rs +++ b/datafusion/substrait/tests/cases/serialize.rs @@ -43,8 +43,8 @@ mod tests { let proto = serializer::deserialize(path).await?; // Check plan equality let plan = from_substrait_plan(&ctx, &proto).await?; - 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)?;