From 533e2b4c72da854f4d9e4a9e2d3d7c35814b7ffd Mon Sep 17 00:00:00 2001 From: comphead Date: Mon, 27 Jun 2022 15:30:09 -0700 Subject: [PATCH] Improve readability of table scan projections in query plans (remove `Some` and `None`) (#2789) * tablescan projection readability fix * Delete limit_push_down.rs * Merge branch 'master' into tablescan-projection-readability * merge fix --- datafusion/core/src/datasource/view.rs | 58 +-- datafusion/core/tests/custom_sources.rs | 2 +- datafusion/core/tests/sql/avro.rs | 2 +- datafusion/core/tests/sql/explain_analyze.rs | 42 +-- datafusion/core/tests/sql/joins.rs | 16 +- datafusion/core/tests/sql/json.rs | 2 +- datafusion/core/tests/sql/projection.rs | 4 +- datafusion/core/tests/sql/udf.rs | 2 +- datafusion/core/tests/user_defined_plan.rs | 4 +- datafusion/expr/src/logical_plan/builder.rs | 34 +- datafusion/expr/src/logical_plan/plan.rs | 26 +- .../optimizer/src/common_subexpr_eliminate.rs | 10 +- datafusion/optimizer/src/eliminate_filter.rs | 8 +- datafusion/optimizer/src/eliminate_limit.rs | 2 +- .../optimizer/src/filter_null_join_keys.rs | 14 +- datafusion/optimizer/src/filter_push_down.rs | 200 +++++----- datafusion/optimizer/src/limit_push_down.rs | 60 +-- .../optimizer/src/projection_push_down.rs | 44 +-- .../optimizer/src/simplify_expressions.rs | 30 +- .../src/single_distinct_to_groupby.rs | 23 +- .../optimizer/src/subquery_filter_to_join.rs | 40 +- datafusion/sql/README.md | 6 +- datafusion/sql/src/planner.rs | 345 +++++++++--------- 23 files changed, 486 insertions(+), 488 deletions(-) diff --git a/datafusion/core/src/datasource/view.rs b/datafusion/core/src/datasource/view.rs index 7ea5329eb5a..9d6b33e3ed0 100644 --- a/datafusion/core/src/datasource/view.rs +++ b/datafusion/core/src/datasource/view.rs @@ -262,15 +262,15 @@ mod tests { .await?; let expected = vec![ - "+---------------+-----------------------------------------------------------------+", - "| plan_type | plan |", - "+---------------+-----------------------------------------------------------------+", - "| logical_plan | CreateView: \"xyz\" |", - "| | Projection: #abc.column1, #abc.column2, #abc.column3 |", - "| | TableScan: abc projection=Some([column1, column2, column3]) |", - "| physical_plan | EmptyExec: produce_one_row=false |", - "| | |", - "+---------------+-----------------------------------------------------------------+", + "+---------------+-----------------------------------------------------------+", + "| plan_type | plan |", + "+---------------+-----------------------------------------------------------+", + "| logical_plan | CreateView: \"xyz\" |", + "| | Projection: #abc.column1, #abc.column2, #abc.column3 |", + "| | TableScan: abc projection=[column1, column2, column3] |", + "| physical_plan | EmptyExec: produce_one_row=false |", + "| | |", + "+---------------+-----------------------------------------------------------+", ]; assert_batches_eq!(expected, &results); @@ -282,16 +282,16 @@ mod tests { .await?; let expected = vec![ - "+---------------+-------------------------------------------------------------------+", - "| plan_type | plan |", - "+---------------+-------------------------------------------------------------------+", - "| logical_plan | CreateView: \"xyz\" |", - "| | Projection: #abc.column1, #abc.column2, #abc.column3 |", - "| | Filter: #abc.column2 = Int64(5) |", - "| | TableScan: abc projection=Some([column1, column2, column3]) |", - "| physical_plan | EmptyExec: produce_one_row=false |", - "| | |", - "+---------------+-------------------------------------------------------------------+", + "+---------------+-------------------------------------------------------------+", + "| plan_type | plan |", + "+---------------+-------------------------------------------------------------+", + "| logical_plan | CreateView: \"xyz\" |", + "| | Projection: #abc.column1, #abc.column2, #abc.column3 |", + "| | Filter: #abc.column2 = Int64(5) |", + "| | TableScan: abc projection=[column1, column2, column3] |", + "| physical_plan | EmptyExec: produce_one_row=false |", + "| | |", + "+---------------+-------------------------------------------------------------+", ]; assert_batches_eq!(expected, &results); @@ -303,16 +303,16 @@ mod tests { .await?; let expected = vec![ - "+---------------+----------------------------------------------------------+", - "| plan_type | plan |", - "+---------------+----------------------------------------------------------+", - "| logical_plan | CreateView: \"xyz\" |", - "| | Projection: #abc.column1, #abc.column2 |", - "| | Filter: #abc.column2 = Int64(5) |", - "| | TableScan: abc projection=Some([column1, column2]) |", - "| physical_plan | EmptyExec: produce_one_row=false |", - "| | |", - "+---------------+----------------------------------------------------------+", + "+---------------+----------------------------------------------------+", + "| plan_type | plan |", + "+---------------+----------------------------------------------------+", + "| logical_plan | CreateView: \"xyz\" |", + "| | Projection: #abc.column1, #abc.column2 |", + "| | Filter: #abc.column2 = Int64(5) |", + "| | TableScan: abc projection=[column1, column2] |", + "| physical_plan | EmptyExec: produce_one_row=false |", + "| | |", + "+---------------+----------------------------------------------------+", ]; assert_batches_eq!(expected, &results); diff --git a/datafusion/core/tests/custom_sources.rs b/datafusion/core/tests/custom_sources.rs index c2861937339..88131313bc3 100644 --- a/datafusion/core/tests/custom_sources.rs +++ b/datafusion/core/tests/custom_sources.rs @@ -239,7 +239,7 @@ async fn custom_source_dataframe() -> Result<()> { let expected = format!( "Projection: #{}.c2\ - \n TableScan: {} projection=Some([c2])", + \n TableScan: {} projection=[c2]", UNNAMED_TABLE, UNNAMED_TABLE ); assert_eq!(format!("{:?}", optimized_plan), expected); diff --git a/datafusion/core/tests/sql/avro.rs b/datafusion/core/tests/sql/avro.rs index e756b435c92..f4ff4cd7cc0 100644 --- a/datafusion/core/tests/sql/avro.rs +++ b/datafusion/core/tests/sql/avro.rs @@ -145,7 +145,7 @@ async fn avro_explain() { "logical_plan", "Projection: #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: alltypes_plain projection=Some([id])", + \n TableScan: alltypes_plain projection=[id]", ], vec![ "physical_plan", diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs index c9719aad662..1ca0a41d4c3 100644 --- a/datafusion/core/tests/sql/explain_analyze.rs +++ b/datafusion/core/tests/sql/explain_analyze.rs @@ -194,7 +194,7 @@ async fn csv_explain_plans() { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #aggregate_test_100.c1 [c1:Utf8]", " Filter: #aggregate_test_100.c2 > Int64(10) [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", - " TableScan: aggregate_test_100 projection=None [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", + " TableScan: aggregate_test_100 [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -209,7 +209,7 @@ async fn csv_explain_plans() { "Explain", " Projection: #aggregate_test_100.c1", " Filter: #aggregate_test_100.c2 > Int64(10)", - " TableScan: aggregate_test_100 projection=None", + " TableScan: aggregate_test_100", ]; let formatted = plan.display_indent().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -231,7 +231,7 @@ async fn csv_explain_plans() { " 2 -> 3 [arrowhead=none, arrowtail=normal, dir=back]", " 4[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\"]", " 3 -> 4 [arrowhead=none, arrowtail=normal, dir=back]", - " 5[shape=box label=\"TableScan: aggregate_test_100 projection=None\"]", + " 5[shape=box label=\"TableScan: aggregate_test_100\"]", " 4 -> 5 [arrowhead=none, arrowtail=normal, dir=back]", " }", " subgraph cluster_6", @@ -242,7 +242,7 @@ async fn csv_explain_plans() { " 7 -> 8 [arrowhead=none, arrowtail=normal, dir=back]", " 9[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", " 8 -> 9 [arrowhead=none, arrowtail=normal, dir=back]", - " 10[shape=box label=\"TableScan: aggregate_test_100 projection=None\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", + " 10[shape=box label=\"TableScan: aggregate_test_100\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", " 9 -> 10 [arrowhead=none, arrowtail=normal, dir=back]", " }", "}", @@ -269,7 +269,7 @@ async fn csv_explain_plans() { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #aggregate_test_100.c1 [c1:Utf8]", " Filter: #aggregate_test_100.c2 > Int64(10) [c1:Utf8, c2:Int32]", - " TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)] [c1:Utf8, c2:Int32]", + " TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)] [c1:Utf8, c2:Int32]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -284,7 +284,7 @@ async fn csv_explain_plans() { "Explain", " Projection: #aggregate_test_100.c1", " Filter: #aggregate_test_100.c2 > Int64(10)", - " TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]", + " TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]", ]; let formatted = plan.display_indent().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -306,7 +306,7 @@ async fn csv_explain_plans() { " 2 -> 3 [arrowhead=none, arrowtail=normal, dir=back]", " 4[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\"]", " 3 -> 4 [arrowhead=none, arrowtail=normal, dir=back]", - " 5[shape=box label=\"TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]\"]", + " 5[shape=box label=\"TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]\"]", " 4 -> 5 [arrowhead=none, arrowtail=normal, dir=back]", " }", " subgraph cluster_6", @@ -317,7 +317,7 @@ async fn csv_explain_plans() { " 7 -> 8 [arrowhead=none, arrowtail=normal, dir=back]", " 9[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\\nSchema: [c1:Utf8, c2:Int32]\"]", " 8 -> 9 [arrowhead=none, arrowtail=normal, dir=back]", - " 10[shape=box label=\"TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]\\nSchema: [c1:Utf8, c2:Int32]\"]", + " 10[shape=box label=\"TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]\\nSchema: [c1:Utf8, c2:Int32]\"]", " 9 -> 10 [arrowhead=none, arrowtail=normal, dir=back]", " }", "}", @@ -392,7 +392,7 @@ async fn csv_explain_verbose_plans() { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #aggregate_test_100.c1 [c1:Utf8]", " Filter: #aggregate_test_100.c2 > Int64(10) [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", - " TableScan: aggregate_test_100 projection=None [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", + " TableScan: aggregate_test_100 [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -407,7 +407,7 @@ async fn csv_explain_verbose_plans() { "Explain", " Projection: #aggregate_test_100.c1", " Filter: #aggregate_test_100.c2 > Int64(10)", - " TableScan: aggregate_test_100 projection=None", + " TableScan: aggregate_test_100", ]; let formatted = plan.display_indent().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -429,7 +429,7 @@ async fn csv_explain_verbose_plans() { " 2 -> 3 [arrowhead=none, arrowtail=normal, dir=back]", " 4[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\"]", " 3 -> 4 [arrowhead=none, arrowtail=normal, dir=back]", - " 5[shape=box label=\"TableScan: aggregate_test_100 projection=None\"]", + " 5[shape=box label=\"TableScan: aggregate_test_100\"]", " 4 -> 5 [arrowhead=none, arrowtail=normal, dir=back]", " }", " subgraph cluster_6", @@ -440,7 +440,7 @@ async fn csv_explain_verbose_plans() { " 7 -> 8 [arrowhead=none, arrowtail=normal, dir=back]", " 9[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", " 8 -> 9 [arrowhead=none, arrowtail=normal, dir=back]", - " 10[shape=box label=\"TableScan: aggregate_test_100 projection=None\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", + " 10[shape=box label=\"TableScan: aggregate_test_100\\nSchema: [c1:Utf8, c2:Int32, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:Int64, c10:Utf8, c11:Float32, c12:Float64, c13:Utf8]\"]", " 9 -> 10 [arrowhead=none, arrowtail=normal, dir=back]", " }", "}", @@ -467,7 +467,7 @@ async fn csv_explain_verbose_plans() { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #aggregate_test_100.c1 [c1:Utf8]", " Filter: #aggregate_test_100.c2 > Int64(10) [c1:Utf8, c2:Int32]", - " TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)] [c1:Utf8, c2:Int32]", + " TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)] [c1:Utf8, c2:Int32]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -482,7 +482,7 @@ async fn csv_explain_verbose_plans() { "Explain", " Projection: #aggregate_test_100.c1", " Filter: #aggregate_test_100.c2 > Int64(10)", - " TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]", + " TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]", ]; let formatted = plan.display_indent().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -504,7 +504,7 @@ async fn csv_explain_verbose_plans() { " 2 -> 3 [arrowhead=none, arrowtail=normal, dir=back]", " 4[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\"]", " 3 -> 4 [arrowhead=none, arrowtail=normal, dir=back]", - " 5[shape=box label=\"TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]\"]", + " 5[shape=box label=\"TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]\"]", " 4 -> 5 [arrowhead=none, arrowtail=normal, dir=back]", " }", " subgraph cluster_6", @@ -515,7 +515,7 @@ async fn csv_explain_verbose_plans() { " 7 -> 8 [arrowhead=none, arrowtail=normal, dir=back]", " 9[shape=box label=\"Filter: #aggregate_test_100.c2 > Int64(10)\\nSchema: [c1:Utf8, c2:Int32]\"]", " 8 -> 9 [arrowhead=none, arrowtail=normal, dir=back]", - " 10[shape=box label=\"TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]\\nSchema: [c1:Utf8, c2:Int32]\"]", + " 10[shape=box label=\"TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]\\nSchema: [c1:Utf8, c2:Int32]\"]", " 9 -> 10 [arrowhead=none, arrowtail=normal, dir=back]", " }", "}", @@ -628,12 +628,12 @@ order by \n Inner Join: #customer.c_nationkey = #nation.n_nationkey\ \n Inner Join: #orders.o_orderkey = #lineitem.l_orderkey\ \n Inner Join: #customer.c_custkey = #orders.o_custkey\ - \n TableScan: customer projection=Some([c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_comment])\ + \n TableScan: customer projection=[c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_comment]\ \n Filter: #orders.o_orderdate >= Date32(\"8674\") AND #orders.o_orderdate < Date32(\"8766\")\ - \n TableScan: orders projection=Some([o_orderkey, o_custkey, o_orderdate]), partial_filters=[#orders.o_orderdate >= Date32(\"8674\"), #orders.o_orderdate < Date32(\"8766\")]\ + \n TableScan: orders projection=[o_orderkey, o_custkey, o_orderdate], partial_filters=[#orders.o_orderdate >= Date32(\"8674\"), #orders.o_orderdate < Date32(\"8766\")]\ \n Filter: #lineitem.l_returnflag = Utf8(\"R\")\ - \n TableScan: lineitem projection=Some([l_orderkey, l_extendedprice, l_discount, l_returnflag]), partial_filters=[#lineitem.l_returnflag = Utf8(\"R\")]\ - \n TableScan: nation projection=Some([n_nationkey, n_name])"; + \n TableScan: lineitem projection=[l_orderkey, l_extendedprice, l_discount, l_returnflag], partial_filters=[#lineitem.l_returnflag = Utf8(\"R\")]\ + \n TableScan: nation projection=[n_nationkey, n_name]"; assert_eq!(format!("{:?}", plan.unwrap()), expected); Ok(()) @@ -753,7 +753,7 @@ async fn csv_explain() { "logical_plan", "Projection: #aggregate_test_100.c1\ \n Filter: #aggregate_test_100.c2 > Int64(10)\ - \n TableScan: aggregate_test_100 projection=Some([c1, c2]), partial_filters=[#aggregate_test_100.c2 > Int64(10)]" + \n TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[#aggregate_test_100.c2 > Int64(10)]" ], vec!["physical_plan", "ProjectionExec: expr=[c1@0 as c1]\ diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rs index 0dd948ca6fb..e4876e6388a 100644 --- a/datafusion/core/tests/sql/joins.rs +++ b/datafusion/core/tests/sql/joins.rs @@ -1221,8 +1221,8 @@ async fn hash_join_with_date32() -> Result<()> { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #t1.c1, #t1.c2, #t1.c3, #t1.c4, #t2.c1, #t2.c2, #t2.c3, #t2.c4 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", " Inner Join: #t1.c1 = #t2.c1 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t1 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t2 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t1 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t2 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -1263,8 +1263,8 @@ async fn hash_join_with_date64() -> Result<()> { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #t1.c1, #t1.c2, #t1.c3, #t1.c4, #t2.c1, #t2.c2, #t2.c3, #t2.c4 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", " Left Join: #t1.c2 = #t2.c2 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t1 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t2 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t1 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t2 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -1307,8 +1307,8 @@ async fn hash_join_with_decimal() -> Result<()> { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #t1.c1, #t1.c2, #t1.c3, #t1.c4, #t2.c1, #t2.c2, #t2.c3, #t2.c4 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", " Right Join: #t1.c3 = #t2.c3 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t1 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t2 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t1 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t2 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); @@ -1351,8 +1351,8 @@ async fn hash_join_with_dictionary() -> Result<()> { "Explain [plan_type:Utf8, plan:Utf8]", " Projection: #t1.c1, #t1.c2, #t1.c3, #t1.c4, #t2.c1, #t2.c2, #t2.c3, #t2.c4 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", " Inner Join: #t1.c4 = #t2.c4 [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N, c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t1 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", - " TableScan: t2 projection=Some([c1, c2, c3, c4]) [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t1 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(5, 2);N, c4:Dictionary(Int32, Utf8);N]", + " TableScan: t2 projection=[c1, c2, c3, c4] [c1:Date32;N, c2:Date64;N, c3:Decimal(10, 2);N, c4:Dictionary(Int32, Utf8);N]", ]; let formatted = plan.display_indent_schema().to_string(); let actual: Vec<&str> = formatted.trim().lines().collect(); diff --git a/datafusion/core/tests/sql/json.rs b/datafusion/core/tests/sql/json.rs index 0fc63ee3a3f..3293ecf43f5 100644 --- a/datafusion/core/tests/sql/json.rs +++ b/datafusion/core/tests/sql/json.rs @@ -88,7 +88,7 @@ async fn json_explain() { "logical_plan", "Projection: #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: t1 projection=Some([a])", + \n TableScan: t1 projection=[a]", ], vec![ "physical_plan", diff --git a/datafusion/core/tests/sql/projection.rs b/datafusion/core/tests/sql/projection.rs index 63b247f2176..a964acae442 100644 --- a/datafusion/core/tests/sql/projection.rs +++ b/datafusion/core/tests/sql/projection.rs @@ -188,7 +188,7 @@ async fn projection_on_table_scan() -> Result<()> { } let expected = "Projection: #test.c2\ - \n TableScan: test projection=Some([c2])"; + \n TableScan: test projection=[c2]"; assert_eq!(format!("{:?}", optimized_plan), expected); let physical_plan = ctx.create_physical_plan(&optimized_plan).await?; @@ -264,7 +264,7 @@ async fn projection_on_memory_scan() -> Result<()> { let expected = format!( "Projection: #{}.b\ - \n TableScan: {} projection=Some([b])", + \n TableScan: {} projection=[b]", UNNAMED_TABLE, UNNAMED_TABLE ); assert_eq!(format!("{:?}", optimized_plan), expected); diff --git a/datafusion/core/tests/sql/udf.rs b/datafusion/core/tests/sql/udf.rs index d9bb4838b2d..705f0abe1f7 100644 --- a/datafusion/core/tests/sql/udf.rs +++ b/datafusion/core/tests/sql/udf.rs @@ -92,7 +92,7 @@ async fn scalar_udf() -> Result<()> { assert_eq!( format!("{:?}", plan), - "Projection: #t.a, #t.b, my_add(#t.a, #t.b)\n TableScan: t projection=Some([a, b])" + "Projection: #t.a, #t.b, my_add(#t.a, #t.b)\n TableScan: t projection=[a, b]" ); let plan = ctx.optimize(&plan)?; diff --git a/datafusion/core/tests/user_defined_plan.rs b/datafusion/core/tests/user_defined_plan.rs index 201beaa78ef..a62168faf64 100644 --- a/datafusion/core/tests/user_defined_plan.rs +++ b/datafusion/core/tests/user_defined_plan.rs @@ -46,7 +46,7 @@ //! | logical_plan | Limit: 3 | //! | | Sort: #revenue DESC NULLS FIRST | //! | | Projection: #customer_id, #revenue | -//! | | TableScan: sales projection=None | +//! | | TableScan: sales | //! +--------------+----------------------------------------+ //! ``` //! @@ -219,7 +219,7 @@ async fn topk_plan() -> Result<()> { let mut expected = vec![ "| logical_plan after topk | TopK: k=3 |", "| | Projection: #sales.customer_id, #sales.revenue |", - "| | TableScan: sales projection=Some([customer_id, revenue]) |", + "| | TableScan: sales projection=[customer_id,revenue] |", ].join("\n"); let explain_query = format!("EXPLAIN VERBOSE {}", QUERY); diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs index 083b66c325a..6692b18d101 100644 --- a/datafusion/expr/src/logical_plan/builder.rs +++ b/datafusion/expr/src/logical_plan/builder.rs @@ -1032,7 +1032,7 @@ mod tests { let expected = "Projection: #employee_csv.id\ \n Filter: #employee_csv.state = Utf8(\"CO\")\ - \n TableScan: employee_csv projection=Some([id, state])"; + \n TableScan: employee_csv projection=[id, state]"; assert_eq!(expected, format!("{:?}", plan)); @@ -1063,9 +1063,9 @@ mod tests { .build()?; let expected = "Limit: skip=2, fetch=10\ - \n Projection: #employee_csv.state, #total_salary\ - \n Aggregate: groupBy=[[#employee_csv.state]], aggr=[[SUM(#employee_csv.salary) AS total_salary]]\ - \n TableScan: employee_csv projection=Some([state, salary])"; + \n Projection: #employee_csv.state, #total_salary\ + \n Aggregate: groupBy=[[#employee_csv.state]], aggr=[[SUM(#employee_csv.salary) AS total_salary]]\ + \n TableScan: employee_csv projection=[state, salary]"; assert_eq!(expected, format!("{:?}", plan)); @@ -1091,7 +1091,7 @@ mod tests { .build()?; let expected = "Sort: #employee_csv.state ASC NULLS FIRST, #employee_csv.salary DESC NULLS LAST\ - \n TableScan: employee_csv projection=Some([state, salary])"; + \n TableScan: employee_csv projection=[state, salary]"; assert_eq!(expected, format!("{:?}", plan)); @@ -1110,8 +1110,8 @@ mod tests { // id column should only show up once in projection let expected = "Projection: #t1.id, #t1.first_name, #t1.last_name, #t1.state, #t1.salary, #t2.first_name, #t2.last_name, #t2.state, #t2.salary\ \n Inner Join: Using #t1.id = #t2.id\ - \n TableScan: t1 projection=None\ - \n TableScan: t2 projection=None"; + \n TableScan: t1\ + \n TableScan: t2"; assert_eq!(expected, format!("{:?}", plan)); @@ -1131,10 +1131,10 @@ mod tests { // output has only one union let expected = "Union\ - \n TableScan: employee_csv projection=Some([state, salary])\ - \n TableScan: employee_csv projection=Some([state, salary])\ - \n TableScan: employee_csv projection=Some([state, salary])\ - \n TableScan: employee_csv projection=Some([state, salary])"; + \n TableScan: employee_csv projection=[state, salary]\ + \n TableScan: employee_csv projection=[state, salary]\ + \n TableScan: employee_csv projection=[state, salary]\ + \n TableScan: employee_csv projection=[state, salary]"; assert_eq!(expected, format!("{:?}", plan)); @@ -1159,8 +1159,8 @@ mod tests { let expected = "Filter: EXISTS (\ Subquery: Filter: #foo.a = #bar.a\ \n Projection: #foo.a\ - \n TableScan: foo projection=None)\ - \n Projection: #bar.a\n TableScan: bar projection=None"; + \n TableScan: foo)\ + \n Projection: #bar.a\n TableScan: bar"; assert_eq!(expected, format!("{:?}", outer_query)); Ok(()) @@ -1184,9 +1184,9 @@ mod tests { let expected = "Filter: #bar.a IN (Subquery: Filter: #foo.a = #bar.a\ \n Projection: #foo.a\ - \n TableScan: foo projection=None)\ + \n TableScan: foo)\ \n Projection: #bar.a\ - \n TableScan: bar projection=None"; + \n TableScan: bar"; assert_eq!(expected, format!("{:?}", outer_query)); Ok(()) @@ -1209,8 +1209,8 @@ mod tests { let expected = "Projection: (Subquery: Filter: #foo.a = #bar.a\ \n Projection: #foo.b\ - \n TableScan: foo projection=None)\ - \n TableScan: bar projection=None"; + \n TableScan: foo)\ + \n TableScan: bar"; assert_eq!(expected, format!("{:?}", outer_query)); Ok(()) diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 10b9b25a03a..002461972d5 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -474,7 +474,7 @@ impl LogicalPlan { /// // Format using display_indent /// let display_string = format!("{}", plan.display_indent()); /// - /// assert_eq!("Filter: #t1.id = Int32(5)\n TableScan: t1 projection=None", + /// assert_eq!("Filter: #t1.id = Int32(5)\n TableScan: t1", /// display_string); /// ``` pub fn display_indent(&self) -> impl fmt::Display + '_ { @@ -498,7 +498,7 @@ impl LogicalPlan { /// ```text /// Projection: #employee.id [id:Int32]\ /// Filter: #employee.state = Utf8(\"CO\") [id:Int32, state:Utf8]\ - /// TableScan: employee projection=Some([0, 3]) [id:Int32, state:Utf8]"; + /// TableScan: employee projection=[0, 3] [id:Int32, state:Utf8]"; /// ``` /// /// ``` @@ -515,7 +515,7 @@ impl LogicalPlan { /// let display_string = format!("{}", plan.display_indent_schema()); /// /// assert_eq!("Filter: #t1.id = Int32(5) [id:Int32]\ - /// \n TableScan: t1 projection=None [id:Int32]", + /// \n TableScan: t1 [id:Int32]", /// display_string); /// ``` pub fn display_indent_schema(&self) -> impl fmt::Display + '_ { @@ -612,7 +612,7 @@ impl LogicalPlan { /// // Format using display /// let display_string = format!("{}", plan.display()); /// - /// assert_eq!("TableScan: t1 projection=None", display_string); + /// assert_eq!("TableScan: t1", display_string); /// ``` pub fn display(&self) -> impl fmt::Display + '_ { // Boilerplate structure to wrap LogicalPlan with something @@ -656,16 +656,12 @@ impl LogicalPlan { .iter() .map(|i| schema.field(*i).name().as_str()) .collect(); - format!("Some([{}])", names.join(", ")) + format!(" projection=[{}]", names.join(", ")) } - _ => "None".to_string(), + _ => "".to_string(), }; - write!( - f, - "TableScan: {} projection={}", - table_name, projected_fields - )?; + write!(f, "TableScan: {}{}", table_name, projected_fields)?; if !filters.is_empty() { let mut full_filter = vec![]; @@ -1373,7 +1369,7 @@ mod tests { let expected = "Projection: #employee_csv.id\ \n Filter: #employee_csv.state = Utf8(\"CO\")\ - \n TableScan: employee_csv projection=Some([id, state])"; + \n TableScan: employee_csv projection=[id, state]"; assert_eq!(expected, format!("{}", plan.display_indent())); } @@ -1384,7 +1380,7 @@ mod tests { let expected = "Projection: #employee_csv.id [id:Int32]\ \n Filter: #employee_csv.state = Utf8(\"CO\") [id:Int32, state:Utf8]\ - \n TableScan: employee_csv projection=Some([id, state]) [id:Int32, state:Utf8]"; + \n TableScan: employee_csv projection=[id, state] [id:Int32, state:Utf8]"; assert_eq!(expected, format!("{}", plan.display_indent_schema())); } @@ -1406,12 +1402,12 @@ mod tests { ); assert!( graphviz.contains( - r#"[shape=box label="TableScan: employee_csv projection=Some([id, state])"]"# + r#"[shape=box label="TableScan: employee_csv projection=[id, state]"]"# ), "\n{}", plan.display_graphviz() ); - assert!(graphviz.contains(r#"[shape=box label="TableScan: employee_csv projection=Some([id, state])\nSchema: [id:Int32, state:Utf8]"]"#), + assert!(graphviz.contains(r#"[shape=box label="TableScan: employee_csv projection=[id, state]\nSchema: [id:Int32, state:Utf8]"]"#), "\n{}", plan.display_graphviz()); assert!( graphviz.contains(r#"// End DataFusion GraphViz Plan"#), diff --git a/datafusion/optimizer/src/common_subexpr_eliminate.rs b/datafusion/optimizer/src/common_subexpr_eliminate.rs index cc859c1c456..c15efb2a352 100644 --- a/datafusion/optimizer/src/common_subexpr_eliminate.rs +++ b/datafusion/optimizer/src/common_subexpr_eliminate.rs @@ -782,7 +782,7 @@ mod test { let expected = "Aggregate: groupBy=[[]], aggr=[[SUM(#BinaryExpr-*BinaryExpr--Column-test.bLiteral1Column-test.a AS test.a * Int32(1) - test.b), SUM(#BinaryExpr-*BinaryExpr--Column-test.bLiteral1Column-test.a AS test.a * Int32(1) - test.b * Int32(1) + #test.c)]]\ \n Projection: #test.a * Int32(1) - #test.b AS BinaryExpr-*BinaryExpr--Column-test.bLiteral1Column-test.a, #test.a, #test.b, #test.c\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -805,7 +805,7 @@ mod test { let expected = "Aggregate: groupBy=[[]], aggr=[[Int32(1) + #AggregateFunction-AVGfalseColumn-test.a AS AVG(test.a), Int32(1) - #AggregateFunction-AVGfalseColumn-test.a AS AVG(test.a)]]\ \n Projection: AVG(#test.a) AS AggregateFunction-AVGfalseColumn-test.a, #test.a, #test.b, #test.c\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -825,7 +825,7 @@ mod test { let expected = "Projection: #BinaryExpr-+Column-test.aLiteral1 AS Int32(1) + test.a AS first, #BinaryExpr-+Column-test.aLiteral1 AS Int32(1) + test.a AS second\ \n Projection: Int32(1) + #test.a AS BinaryExpr-+Column-test.aLiteral1, #test.a, #test.b, #test.c\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -844,7 +844,7 @@ mod test { .build()?; let expected = "Projection: Int32(1) + #test.a, #test.a + Int32(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -862,7 +862,7 @@ mod test { let expected = "Projection: #Int32(1) + test.a\ \n Projection: Int32(1) + #test.a\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); diff --git a/datafusion/optimizer/src/eliminate_filter.rs b/datafusion/optimizer/src/eliminate_filter.rs index 86cd3bb8d71..10204318882 100644 --- a/datafusion/optimizer/src/eliminate_filter.rs +++ b/datafusion/optimizer/src/eliminate_filter.rs @@ -133,7 +133,7 @@ mod tests { let expected = "Union\ \n EmptyRelation\ \n Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -151,7 +151,7 @@ mod tests { .unwrap(); let expected = "Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -178,9 +178,9 @@ mod tests { // Filter is removed let expected = "Union\ \n Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b)]]\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } } diff --git a/datafusion/optimizer/src/eliminate_limit.rs b/datafusion/optimizer/src/eliminate_limit.rs index 822b03a4aed..931e7204c84 100644 --- a/datafusion/optimizer/src/eliminate_limit.rs +++ b/datafusion/optimizer/src/eliminate_limit.rs @@ -125,7 +125,7 @@ mod tests { let expected = "Union\ \n EmptyRelation\ \n Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } } diff --git a/datafusion/optimizer/src/filter_null_join_keys.rs b/datafusion/optimizer/src/filter_null_join_keys.rs index fd2521c6895..c17a8088d2a 100644 --- a/datafusion/optimizer/src/filter_null_join_keys.rs +++ b/datafusion/optimizer/src/filter_null_join_keys.rs @@ -161,8 +161,8 @@ mod tests { let plan = build_plan(t1, t2, "t1.optional_id", "t2.id")?; let expected = "Inner Join: #t1.optional_id = #t2.id\ \n Filter: #t1.optional_id IS NOT NULL\ - \n TableScan: t1 projection=None\ - \n TableScan: t2 projection=None"; + \n TableScan: t1\ + \n TableScan: t2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -173,8 +173,8 @@ mod tests { let plan = build_plan(t1, t2, "t2.id", "t1.optional_id")?; let expected = "Inner Join: #t1.optional_id = #t2.id\ \n Filter: #t1.optional_id IS NOT NULL\ - \n TableScan: t1 projection=None\ - \n TableScan: t2 projection=None"; + \n TableScan: t1\ + \n TableScan: t2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -208,11 +208,11 @@ mod tests { .build()?; let expected = "Inner Join: #t3.t1_id = #t1.id, #t3.t2_id = #t2.id\ \n Filter: #t3.t1_id IS NOT NULL AND #t3.t2_id IS NOT NULL\ - \n TableScan: t3 projection=None\ + \n TableScan: t3\ \n Inner Join: #t1.optional_id = #t2.id\ \n Filter: #t1.optional_id IS NOT NULL\ - \n TableScan: t1 projection=None\ - \n TableScan: t2 projection=None"; + \n TableScan: t1\ + \n TableScan: t2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } diff --git a/datafusion/optimizer/src/filter_push_down.rs b/datafusion/optimizer/src/filter_push_down.rs index bd44ebea13d..3de4b5a5914 100644 --- a/datafusion/optimizer/src/filter_push_down.rs +++ b/datafusion/optimizer/src/filter_push_down.rs @@ -687,7 +687,7 @@ mod tests { let expected = "\ Projection: #test.a, #test.b\ \n Filter: #test.a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -705,7 +705,7 @@ mod tests { Filter: #test.a = Int64(1)\ \n Limit: skip=None, fetch=10\ \n Projection: #test.a, #test.b\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -718,7 +718,7 @@ mod tests { .build()?; let expected = "\ Filter: Int64(0) = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -736,7 +736,7 @@ mod tests { Projection: #test.c, #test.b\ \n Projection: #test.a, #test.b, #test.c\ \n Filter: #test.a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -752,7 +752,7 @@ mod tests { let expected = "\ Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b) AS total_salary]]\ \n Filter: #test.a > Int64(10)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -768,7 +768,7 @@ mod tests { let expected = "\ Filter: #b > Int64(10)\ \n Aggregate: groupBy=[[#test.a]], aggr=[[SUM(#test.b) AS b]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -785,7 +785,7 @@ mod tests { let expected = "\ Projection: #test.a AS b, #test.c\ \n Filter: #test.a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -824,14 +824,14 @@ mod tests { "\ Filter: #b = Int64(1)\ \n Projection: #test.a * Int32(2) + #test.c AS b, #test.c\ - \n TableScan: test projection=None" + \n TableScan: test" ); // filter is before projection let expected = "\ Projection: #test.a * Int32(2) + #test.c AS b, #test.c\ \n Filter: #test.a * Int32(2) + #test.c = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -857,7 +857,7 @@ mod tests { Filter: #a = Int64(1)\ \n Projection: #b * Int32(3) AS a, #test.c\ \n Projection: #test.a * Int32(2) + #test.c AS b, #test.c\ - \n TableScan: test projection=None" + \n TableScan: test" ); // filter is before the projections @@ -865,7 +865,7 @@ mod tests { Projection: #b * Int32(3) AS a, #test.c\ \n Projection: #test.a * Int32(2) + #test.c AS b, #test.c\ \n Filter: #test.a * Int32(2) + #test.c * Int32(3) = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -891,7 +891,7 @@ mod tests { \n Filter: #b > Int64(10)\ \n Aggregate: groupBy=[[#b]], aggr=[[SUM(#test.c)]]\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None" + \n TableScan: test" ); // filter is before the projections @@ -900,7 +900,7 @@ mod tests { \n Aggregate: groupBy=[[#b]], aggr=[[SUM(#test.c)]]\ \n Projection: #test.a AS b, #test.c\ \n Filter: #test.a > Int64(10)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -928,7 +928,7 @@ mod tests { Filter: #SUM(test.c) > Int64(10) AND #b > Int64(10) AND #SUM(test.c) < Int64(20)\ \n Aggregate: groupBy=[[#b]], aggr=[[SUM(#test.c)]]\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None" + \n TableScan: test" ); // filter is before the projections @@ -937,7 +937,7 @@ mod tests { \n Aggregate: groupBy=[[#b]], aggr=[[SUM(#test.c)]]\ \n Projection: #test.a AS b, #test.c\ \n Filter: #test.a > Int64(10)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -961,7 +961,7 @@ mod tests { \n Limit: skip=None, fetch=10\ \n Limit: skip=None, fetch=20\ \n Projection: #test.a, #test.b\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -977,9 +977,9 @@ mod tests { let expected = "\ Union\ \n Filter: #a = Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Filter: #a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -998,9 +998,9 @@ mod tests { let expected = "\ Union\ \n Filter: #a = Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Filter: #a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1026,7 +1026,7 @@ mod tests { \n Limit: skip=None, fetch=1\ \n Filter: #test.a <= Int64(1)\ \n Projection: #test.a\ - \n TableScan: test projection=None" + \n TableScan: test" ); let expected = "\ @@ -1035,7 +1035,7 @@ mod tests { \n Limit: skip=None, fetch=1\ \n Projection: #test.a\ \n Filter: #test.a <= Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -1059,14 +1059,14 @@ mod tests { \n Filter: #test.a >= Int64(1)\ \n Filter: #test.a <= Int64(1)\ \n Limit: skip=None, fetch=1\ - \n TableScan: test projection=None" + \n TableScan: test" ); let expected = "\ Projection: #test.a\ \n Filter: #test.a >= Int64(1) AND #test.a <= Int64(1)\ \n Limit: skip=None, fetch=1\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -1086,7 +1086,7 @@ mod tests { let expected = "\ TestUserDefined\ \n Filter: #test.a <= Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; // not part of the test assert_eq!(format!("{:?}", plan), expected); @@ -1120,19 +1120,19 @@ mod tests { "\ Filter: #test.a <= Int64(1)\ \n Inner Join: #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter sent to side before the join let expected = "\ Inner Join: #test.a = #test2.a\ \n Filter: #test.a <= Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ \n Filter: #test2.a <= Int64(1)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1161,19 +1161,19 @@ mod tests { "\ Filter: #test.a <= Int64(1)\ \n Inner Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter sent to side before the join let expected = "\ Inner Join: Using #test.a = #test2.a\ \n Filter: #test.a <= Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ \n Filter: #test2.a <= Int64(1)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1207,9 +1207,9 @@ mod tests { Filter: #test.c <= #test2.b\ \n Inner Join: #test.a = #test2.a\ \n Projection: #test.a, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // expected is equal: no push-down @@ -1247,18 +1247,18 @@ mod tests { Filter: #test.b <= Int64(1)\ \n Inner Join: #test.a = #test2.a\ \n Projection: #test.a, #test.b\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Inner Join: #test.a = #test2.a\ \n Projection: #test.a, #test.b\ \n Filter: #test.b <= Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.c\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1288,18 +1288,18 @@ mod tests { "\ Filter: #test2.a <= Int64(1)\ \n Left Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter not duplicated nor pushed down - i.e. noop let expected = "\ Filter: #test2.a <= Int64(1)\ \n Left Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1329,18 +1329,18 @@ mod tests { "\ Filter: #test.a <= Int64(1)\ \n Right Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter not duplicated nor pushed down - i.e. noop let expected = "\ Filter: #test.a <= Int64(1)\ \n Right Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1370,18 +1370,18 @@ mod tests { "\ Filter: #test.a <= Int64(1)\ \n Left Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter sent to left side of the join, not the right let expected = "\ Left Join: Using #test.a = #test2.a\ \n Filter: #test.a <= Int64(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1411,18 +1411,18 @@ mod tests { "\ Filter: #test2.a <= Int64(1)\ \n Right Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // filter sent to right side of join, not duplicated to the left let expected = "\ Right Join: Using #test.a = #test2.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a\ \n Filter: #test2.a <= Int64(1)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1457,19 +1457,19 @@ mod tests { "\ 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 projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Inner Join: #test.a = #test2.a Filter: #test.b < #test2.b\ \n Projection: #test.a, #test.b, #test.c\ \n Filter: #test.c > UInt32(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ \n Filter: #test2.c > UInt32(4)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1503,19 +1503,19 @@ mod tests { "\ 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 projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Inner Join: #test.a = #test2.a\ \n Projection: #test.a, #test.b, #test.c\ \n Filter: #test.b > UInt32(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ \n Filter: #test2.c > UInt32(4)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1547,19 +1547,19 @@ mod tests { "\ Inner Join: #test.a = #test2.b Filter: #test.a > UInt32(1)\ \n Projection: #test.a\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.b\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Inner Join: #test.a = #test2.b\ \n Projection: #test.a\ \n Filter: #test.a > UInt32(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.b\ \n Filter: #test2.b > UInt32(1)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1594,18 +1594,18 @@ mod tests { "\ 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 projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Left Join: #test.a = #test2.a Filter: #test.a > UInt32(1) AND #test.b < #test2.b\ \n Projection: #test.a, #test.b, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ \n Filter: #test2.c > UInt32(4)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1640,18 +1640,18 @@ mod tests { "\ 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 projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = "\ Right Join: #test.a = #test2.a Filter: #test.b < #test2.b AND #test2.c > UInt32(4)\ \n Projection: #test.a, #test.b, #test.c\ \n Filter: #test.a > UInt32(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1686,9 +1686,9 @@ mod tests { "\ 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 projection=None\ + \n TableScan: test\ \n Projection: #test2.a, #test2.b, #test2.c\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); let expected = &format!("{:?}", plan); @@ -1759,7 +1759,7 @@ mod tests { let plan = table_scan_with_pushdown_provider(TableProviderFilterPushDown::Exact)?; let expected = "\ - TableScan: test projection=None, full_filters=[#a = Int64(1)]"; + TableScan: test, full_filters=[#a = Int64(1)]"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1771,7 +1771,7 @@ mod tests { let expected = "\ Filter: #a = Int64(1)\ - \n TableScan: test projection=None, partial_filters=[#a = Int64(1)]"; + \n TableScan: test, partial_filters=[#a = Int64(1)]"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1785,7 +1785,7 @@ mod tests { let expected = "\ Filter: #a = Int64(1)\ - \n TableScan: test projection=None, partial_filters=[#a = Int64(1)]"; + \n TableScan: test, partial_filters=[#a = Int64(1)]"; // Optimizing the same plan multiple times should produce the same plan // each time. @@ -1800,7 +1800,7 @@ mod tests { let expected = "\ Filter: #a = Int64(1)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1829,7 +1829,7 @@ mod tests { let expected ="Projection: #a, #b\ \n Filter: #a = Int64(10) AND #b > Int64(11)\ - \n TableScan: test projection=Some([a]), partial_filters=[#a = Int64(10), #b > Int64(11)]"; + \n TableScan: test projection=[a], partial_filters=[#a = Int64(10), #b > Int64(11)]"; assert_optimized_plan_eq(&plan, expected); @@ -1853,7 +1853,7 @@ mod tests { "\ Filter: #b > Int64(10) AND #test.c > Int64(10)\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ " ); @@ -1861,7 +1861,7 @@ mod tests { let expected = "\ Projection: #test.a AS b, #test.c\ \n Filter: #test.a > Int64(10) AND #test.c > Int64(10)\ - \n TableScan: test projection=None\ + \n TableScan: test\ "; assert_optimized_plan_eq(&plan, expected); @@ -1888,7 +1888,7 @@ mod tests { Filter: #b > Int64(10) AND #test.c > Int64(10)\ \n Projection: #b, #test.c\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ " ); @@ -1897,7 +1897,7 @@ mod tests { Projection: #b, #test.c\ \n Projection: #test.a AS b, #test.c\ \n Filter: #test.a > Int64(10) AND #test.c > Int64(10)\ - \n TableScan: test projection=None\ + \n TableScan: test\ "; assert_optimized_plan_eq(&plan, expected); @@ -1919,7 +1919,7 @@ mod tests { "\ Filter: #b > Int64(10) AND #d > Int64(10)\ \n Projection: #test.a AS b, #test.c AS d\ - \n TableScan: test projection=None\ + \n TableScan: test\ " ); @@ -1927,7 +1927,7 @@ mod tests { let expected = "\ Projection: #test.a AS b, #test.c AS d\ \n Filter: #test.a > Int64(10) AND #test.c > Int64(10)\ - \n TableScan: test projection=None\ + \n TableScan: test\ "; assert_optimized_plan_eq(&plan, expected); @@ -1961,9 +1961,9 @@ mod tests { "\ Inner Join: #c = #d Filter: #c > UInt32(1)\ \n Projection: #test.a AS c\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.b AS d\ - \n TableScan: test2 projection=None" + \n TableScan: test2" ); // Change filter on col `c`, 'd' to `test.a`, 'test.b' @@ -1971,10 +1971,10 @@ mod tests { Inner Join: #c = #d\ \n Projection: #test.a AS c\ \n Filter: #test.a > UInt32(1)\ - \n TableScan: test projection=None\ + \n TableScan: test\ \n Projection: #test2.b AS d\ \n Filter: #test2.b > UInt32(1)\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -1997,7 +1997,7 @@ mod tests { "\ Filter: #b IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ " ); @@ -2005,7 +2005,7 @@ mod tests { let expected = "\ Projection: #test.a AS b, #test.c\ \n Filter: #test.a IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ - \n TableScan: test projection=None\ + \n TableScan: test\ "; assert_optimized_plan_eq(&plan, expected); @@ -2033,7 +2033,7 @@ mod tests { Filter: #b IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ \n Projection: #b, #test.c\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None\ + \n TableScan: test\ " ); @@ -2042,7 +2042,7 @@ mod tests { Projection: #b, #test.c\ \n Projection: #test.a AS b, #test.c\ \n Filter: #test.a IN ([UInt32(1), UInt32(2), UInt32(3), UInt32(4)])\ - \n TableScan: test projection=None\ + \n TableScan: test\ "; assert_optimized_plan_eq(&plan, expected); @@ -2068,16 +2068,16 @@ mod tests { // filter on col b in subquery let expected_before = "\ - Filter: #b IN (Subquery: Projection: #sq.c\n TableScan: sq projection=None)\ + Filter: #b IN (Subquery: Projection: #sq.c\n TableScan: sq)\ \n Projection: #test.a AS b, #test.c\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_eq!(format!("{:?}", plan), expected_before); // rewrite filter col b to test.a let expected_after = "\ Projection: #test.a AS b, #test.c\ - \n Filter: #test.a IN (Subquery: Projection: #sq.c\n TableScan: sq projection=None)\ - \n TableScan: test projection=None"; + \n Filter: #test.a IN (Subquery: Projection: #sq.c\n TableScan: sq)\ + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected_after); Ok(()) diff --git a/datafusion/optimizer/src/limit_push_down.rs b/datafusion/optimizer/src/limit_push_down.rs index 1775ac5e0e9..6ff30e78d89 100644 --- a/datafusion/optimizer/src/limit_push_down.rs +++ b/datafusion/optimizer/src/limit_push_down.rs @@ -377,7 +377,7 @@ mod test { // When it has a select let expected = "Limit: skip=None, fetch=1000\ \n Projection: #test.a\ - \n TableScan: test projection=None, fetch=1000"; + \n TableScan: test, fetch=1000"; assert_optimized_plan_eq(&plan, expected); @@ -397,7 +397,7 @@ mod test { // This rule doesn't replace multiple limits let expected = "Limit: skip=None, fetch=10\ \n Limit: skip=None, fetch=10\ - \n TableScan: test projection=None, fetch=10"; + \n TableScan: test, fetch=10"; assert_optimized_plan_eq(&plan, expected); @@ -416,7 +416,7 @@ mod test { // Limit should *not* push down aggregate node let expected = "Limit: skip=None, fetch=1000\ \n Aggregate: groupBy=[[#test.a]], aggr=[[MAX(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -436,9 +436,9 @@ mod test { let expected = "Limit: skip=None, fetch=1000\ \n Union\ \n Limit: skip=None, fetch=1000\ - \n TableScan: test projection=None, fetch=1000\ + \n TableScan: test, fetch=1000\ \n Limit: skip=None, fetch=1000\ - \n TableScan: test projection=None, fetch=1000"; + \n TableScan: test, fetch=1000"; assert_optimized_plan_eq(&plan, expected); @@ -459,7 +459,7 @@ mod test { let expected = "Limit: skip=None, fetch=10\ \n Aggregate: groupBy=[[#test.a]], aggr=[[MAX(#test.b)]]\ \n Limit: skip=None, fetch=1000\ - \n TableScan: test projection=None, fetch=1000"; + \n TableScan: test, fetch=1000"; assert_optimized_plan_eq(&plan, expected); @@ -476,7 +476,7 @@ mod test { // Should not push any limit down to table provider // When it has a select let expected = "Limit: skip=10, fetch=None\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -495,7 +495,7 @@ mod test { // When it has a select let expected = "Limit: skip=10, fetch=1000\ \n Projection: #test.a\ - \n TableScan: test projection=None, fetch=1010"; + \n TableScan: test, fetch=1010"; assert_optimized_plan_eq(&plan, expected); @@ -515,7 +515,7 @@ mod test { let expected = "Limit: skip=10, fetch=None\ \n Limit: skip=None, fetch=1000\ \n Projection: #test.a\ - \n TableScan: test projection=None, fetch=1000"; + \n TableScan: test, fetch=1000"; assert_optimized_plan_eq(&plan, expected); @@ -535,7 +535,7 @@ mod test { let expected = "Limit: skip=None, fetch=1000\ \n Limit: skip=10, fetch=1000\ \n Projection: #test.a\ - \n TableScan: test projection=None, fetch=1010"; + \n TableScan: test, fetch=1010"; assert_optimized_plan_eq(&plan, expected); @@ -558,7 +558,7 @@ mod test { let expected = "Limit: skip=None, fetch=10\ \n Limit: skip=None, fetch=10\ \n Limit: skip=10, fetch=10\ - \n TableScan: test projection=None, fetch=20"; + \n TableScan: test, fetch=20"; assert_optimized_plan_eq(&plan, expected); @@ -577,7 +577,7 @@ mod test { // Limit should *not* push down aggregate node let expected = "Limit: skip=10, fetch=1000\ \n Aggregate: groupBy=[[#test.a]], aggr=[[MAX(#test.b)]]\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); @@ -597,9 +597,9 @@ mod test { let expected = "Limit: skip=10, fetch=1000\ \n Union\ \n Limit: skip=None, fetch=1010\ - \n TableScan: test projection=None, fetch=1010\ + \n TableScan: test, fetch=1010\ \n Limit: skip=None, fetch=1010\ - \n TableScan: test projection=None, fetch=1010"; + \n TableScan: test, fetch=1010"; assert_optimized_plan_eq(&plan, expected); @@ -624,8 +624,8 @@ mod test { // Limit pushdown Not supported in Join let expected = "Limit: skip=10, fetch=1000\ \n Inner Join: #test.a = #test2.a\ - \n TableScan: test projection=None\ - \n TableScan: test2 projection=None"; + \n TableScan: test\ + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); @@ -650,8 +650,8 @@ mod test { // Limit pushdown Not supported in Join let expected = "Limit: skip=10, fetch=1000\ \n Inner Join: #test.a = #test2.a\ - \n TableScan: test projection=None\ - \n TableScan: test2 projection=None"; + \n TableScan: test\ + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); @@ -678,9 +678,9 @@ mod test { let expected = "Limit: skip=10, fetch=100\ \n Filter: EXISTS (Subquery: Filter: #test1.a = #test1.a\ \n Projection: #test1.a\ - \n TableScan: test1 projection=None)\ + \n TableScan: test1)\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&outer_query, expected); @@ -707,9 +707,9 @@ mod test { let expected = "Limit: skip=10, fetch=100\ \n Filter: EXISTS (Subquery: Filter: #test1.a = #test1.a\ \n Projection: #test1.a\ - \n TableScan: test1 projection=None)\ + \n TableScan: test1)\ \n Projection: #test2.a\ - \n TableScan: test2 projection=None"; + \n TableScan: test2"; assert_optimized_plan_eq(&outer_query, expected); @@ -734,8 +734,8 @@ mod test { // Limit pushdown Not supported in Join let expected = "Limit: skip=None, fetch=1000\ \n Left Join: #test.a = #test2.a\ - \n TableScan: test projection=None, fetch=1000\ - \n TableScan: test2 projection=None"; + \n TableScan: test, fetch=1000\ + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); @@ -760,8 +760,8 @@ mod test { // Limit pushdown Not supported in Join let expected = "Limit: skip=10, fetch=1000\ \n Left Join: #test.a = #test2.a\ - \n TableScan: test projection=None, fetch=1010\ - \n TableScan: test2 projection=None"; + \n TableScan: test, fetch=1010\ + \n TableScan: test2"; assert_optimized_plan_eq(&plan, expected); @@ -786,8 +786,8 @@ mod test { // Limit pushdown Not supported in Join let expected = "Limit: skip=None, fetch=1000\ \n Right Join: #test.a = #test2.a\ - \n TableScan: test projection=None\ - \n TableScan: test2 projection=None, fetch=1000"; + \n TableScan: test\ + \n TableScan: test2, fetch=1000"; assert_optimized_plan_eq(&plan, expected); @@ -812,8 +812,8 @@ mod test { // Limit pushdown with offset supported in right outer join let expected = "Limit: skip=10, fetch=1000\ \n Right Join: #test.a = #test2.a\ - \n TableScan: test projection=None\ - \n TableScan: test2 projection=None, fetch=1010"; + \n TableScan: test\ + \n TableScan: test2, fetch=1010"; assert_optimized_plan_eq(&plan, expected); diff --git a/datafusion/optimizer/src/projection_push_down.rs b/datafusion/optimizer/src/projection_push_down.rs index ae2cc4fce87..83dee97174f 100644 --- a/datafusion/optimizer/src/projection_push_down.rs +++ b/datafusion/optimizer/src/projection_push_down.rs @@ -552,7 +552,7 @@ mod tests { .build()?; let expected = "Aggregate: groupBy=[[]], aggr=[[MAX(#test.b)]]\ - \n TableScan: test projection=Some([b])"; + \n TableScan: test projection=[b]"; assert_optimized_plan_eq(&plan, expected); @@ -568,7 +568,7 @@ mod tests { .build()?; let expected = "Aggregate: groupBy=[[#test.c]], aggr=[[MAX(#test.b)]]\ - \n TableScan: test projection=Some([b, c])"; + \n TableScan: test projection=[b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -586,7 +586,7 @@ mod tests { let expected = "Aggregate: groupBy=[[#a.c]], aggr=[[MAX(#a.b)]]\ \n SubqueryAlias: a\ - \n TableScan: test projection=Some([b, c])"; + \n TableScan: test projection=[b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -604,7 +604,7 @@ mod tests { let expected = "Aggregate: groupBy=[[]], aggr=[[MAX(#test.b)]]\ \n Filter: #test.c\ - \n TableScan: test projection=Some([b, c])"; + \n TableScan: test projection=[b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -620,7 +620,7 @@ mod tests { .project(vec![col("a"), col("c"), col("b")])? .build()?; let expected = "Projection: #test.a, #test.c, #test.b\ - \n TableScan: test projection=Some([a, b, c])"; + \n TableScan: test projection=[a, b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -635,7 +635,7 @@ mod tests { .project(vec![col("c"), col("b"), col("a")])? .build()?; let expected = "Projection: #test.c, #test.b, #test.a\ - \n TableScan: test projection=Some([a, b, c])"; + \n TableScan: test projection=[a, b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -658,7 +658,7 @@ mod tests { \n Filter: #test.a > Int32(1)\ \n Filter: #test.b > Int32(1)\ \n Filter: #test.c > Int32(1)\ - \n TableScan: test projection=Some([a, b, c])"; + \n TableScan: test projection=[a, b, c]"; assert_optimized_plan_eq(&plan, expected); @@ -680,8 +680,8 @@ mod tests { // make sure projections are pushed down to both table scans let expected = "Projection: #test.a, #test.b, #test2.c1\ \n Left Join: #test.a = #test2.c1\ - \n TableScan: test projection=Some([a, b])\ - \n TableScan: test2 projection=Some([c1])"; + \n TableScan: test projection=[a, b]\ + \n TableScan: test2 projection=[c1]"; let optimized_plan = optimize(&plan)?; let formatted_plan = format!("{:?}", optimized_plan); @@ -723,8 +723,8 @@ mod tests { // make sure projections are pushed down to both table scans let expected = "Projection: #test.a, #test.b\ \n Left Join: #test.a = #test2.c1\ - \n TableScan: test projection=Some([a, b])\ - \n TableScan: test2 projection=Some([c1])"; + \n TableScan: test projection=[a, b]\ + \n TableScan: test2 projection=[c1]"; let optimized_plan = optimize(&plan)?; let formatted_plan = format!("{:?}", optimized_plan); @@ -764,8 +764,8 @@ mod tests { // make sure projections are pushed down to table scan let expected = "Projection: #test.a, #test.b\ \n Left Join: Using #test.a = #test2.a\ - \n TableScan: test projection=Some([a, b])\ - \n TableScan: test2 projection=Some([a])"; + \n TableScan: test projection=[a, b]\ + \n TableScan: test2 projection=[a]"; let optimized_plan = optimize(&plan)?; let formatted_plan = format!("{:?}", optimized_plan); @@ -800,7 +800,7 @@ mod tests { .build()?; let expected = "Projection: CAST(#test.c AS Float64)\ - \n TableScan: test projection=Some([c])"; + \n TableScan: test projection=[c]"; assert_optimized_plan_eq(&projection, expected); @@ -820,7 +820,7 @@ mod tests { assert_fields_eq(&plan, vec!["a", "b"]); let expected = "Projection: #test.a, #test.b\ - \n TableScan: test projection=Some([a, b])"; + \n TableScan: test projection=[a, b]"; assert_optimized_plan_eq(&plan, expected); @@ -854,7 +854,7 @@ mod tests { assert_fields_eq(&plan, vec!["a", "b"]); let expected = "Projection: #a, #b\ - \n TableScan: test projection=Some([a, b])"; + \n TableScan: test projection=[a, b]"; assert_optimized_plan_eq(&plan, expected); @@ -876,7 +876,7 @@ mod tests { let expected = "Limit: skip=None, fetch=5\ \n Projection: #test.c, #test.a\ - \n TableScan: test projection=Some([a, c])"; + \n TableScan: test projection=[a, c]"; assert_optimized_plan_eq(&plan, expected); @@ -888,7 +888,7 @@ mod tests { let table_scan = test_table_scan()?; let plan = LogicalPlanBuilder::from(table_scan).build()?; // should expand projection to all columns without projection - let expected = "TableScan: test projection=Some([a, b, c])"; + let expected = "TableScan: test projection=[a, b, c]"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -900,7 +900,7 @@ mod tests { .project(vec![lit(1_i64), lit(2_i64)])? .build()?; let expected = "Projection: Int64(1), Int64(2)\ - \n TableScan: test projection=Some([a])"; + \n TableScan: test projection=[a]"; assert_optimized_plan_eq(&plan, expected); Ok(()) } @@ -925,7 +925,7 @@ mod tests { Aggregate: groupBy=[[#test.c]], aggr=[[MAX(#test.a)]]\ \n Filter: #test.c > Int32(1)\ \n Projection: #test.c, #test.a\ - \n TableScan: test projection=Some([a, c])"; + \n TableScan: test projection=[a, c]"; assert_optimized_plan_eq(&plan, expected); @@ -949,7 +949,7 @@ mod tests { let expected = "\ Projection: Int32(1) AS a\ - \n TableScan: test projection=Some([a])"; + \n TableScan: test projection=[a]"; assert_optimized_plan_eq(&plan, expected); @@ -995,7 +995,7 @@ mod tests { let expected = "Projection: #test.c, #test.a, #MAX(test.b)\ \n Filter: #test.c > Int32(1)\ \n Aggregate: groupBy=[[#test.a, #test.c]], aggr=[[MAX(#test.b)]]\ - \n TableScan: test projection=Some([a, b, c])"; + \n TableScan: test projection=[a, b, c]"; assert_optimized_plan_eq(&plan, expected); diff --git a/datafusion/optimizer/src/simplify_expressions.rs b/datafusion/optimizer/src/simplify_expressions.rs index e40180f6945..aa089a00a6a 100644 --- a/datafusion/optimizer/src/simplify_expressions.rs +++ b/datafusion/optimizer/src/simplify_expressions.rs @@ -1572,7 +1572,7 @@ mod tests { "\ Filter: #test.b > Int32(1) AS test.b > Int32(1) AND test.b > Int32(1)\ \n Projection: #test.a\ - \n TableScan: test projection=None", + \n TableScan: test", ); } @@ -1596,7 +1596,7 @@ mod tests { "\ Filter: #test.a > Int32(5) AND #test.b < Int32(6) AS test.a > Int32(5) AND test.b < Int32(6) AND test.a > Int32(5)\ \n Projection: #test.a, #test.b\ - \n TableScan: test projection=None", + \n TableScan: test", ); } @@ -1617,7 +1617,7 @@ mod tests { Projection: #test.a\ \n Filter: NOT #test.c AS test.c = Boolean(false)\ \n Filter: #test.b AS test.b = Boolean(true)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1642,7 +1642,7 @@ mod tests { \n Limit: skip=None, fetch=1\ \n Filter: #test.c AS test.c != Boolean(false)\ \n Filter: NOT #test.b AS test.b != Boolean(true)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1661,7 +1661,7 @@ mod tests { let expected = "\ Projection: #test.a\ \n Filter: NOT #test.b AND #test.c AS test.b != Boolean(true) AND test.c = Boolean(true)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1680,7 +1680,7 @@ mod tests { let expected = "\ Projection: #test.a\ \n Filter: NOT #test.b OR NOT #test.c AS test.b != Boolean(true) OR test.c = Boolean(false)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1699,7 +1699,7 @@ mod tests { let expected = "\ Projection: #test.a\ \n Filter: #test.b AS NOT test.b = Boolean(false)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1715,7 +1715,7 @@ mod tests { let expected = "\ Projection: #test.a, #test.d, NOT #test.b AS test.b = Boolean(false)\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1740,7 +1740,7 @@ mod tests { let expected = "\ Aggregate: groupBy=[[#test.a, #test.c]], aggr=[[MAX(#test.b) AS MAX(test.b = Boolean(true)), MIN(#test.b)]]\ \n Projection: #test.a, #test.c, #test.b\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_optimized_plan_eq(&plan, expected); } @@ -1805,7 +1805,7 @@ mod tests { .unwrap(); let expected = "Projection: TimestampNanosecond(1599566400000000000, None) AS totimestamp(Utf8(\"2020-09-08T12:00:00+00:00\"))\ - \n TableScan: test projection=None" + \n TableScan: test" .to_string(); let actual = get_optimized_plan_formatted(&plan, &Utc::now()); assert_eq!(expected, actual); @@ -1840,7 +1840,7 @@ mod tests { .unwrap(); let expected = "Projection: Int32(0) AS CAST(Utf8(\"0\") AS Int32)\ - \n TableScan: test projection=None"; + \n TableScan: test"; let actual = get_optimized_plan_formatted(&plan, &Utc::now()); assert_eq!(expected, actual); } @@ -1882,7 +1882,7 @@ mod tests { let actual = get_optimized_plan_formatted(&plan, &time); let expected = format!( "Projection: TimestampNanosecond({}, Some(\"UTC\")) AS now(), TimestampNanosecond({}, Some(\"UTC\")) AS t2\ - \n TableScan: test projection=None", + \n TableScan: test", time.timestamp_nanos(), time.timestamp_nanos() ); @@ -1907,7 +1907,7 @@ mod tests { let actual = get_optimized_plan_formatted(&plan, &time); let expected = "Projection: NOT #test.a AS Boolean(true) OR Boolean(false) != test.a\ - \n TableScan: test projection=None"; + \n TableScan: test"; assert_eq!(actual, expected); } @@ -1932,7 +1932,7 @@ mod tests { // Note that constant folder runs and folds the entire // expression down to a single constant (true) let expected = "Filter: Boolean(true) AS CAST(now() AS Int64) < CAST(totimestamp(Utf8(\"2020-09-08T12:05:00+00:00\")) AS Int64) + Int32(50000)\ - \n TableScan: test projection=None"; + \n TableScan: test"; let actual = get_optimized_plan_formatted(&plan, &time); assert_eq!(expected, actual); @@ -1964,7 +1964,7 @@ mod tests { // Note that constant folder runs and folds the entire // expression down to a single constant (true) let expected = "Projection: Date32(\"18636\") AS CAST(totimestamp(Utf8(\"2020-09-08T12:05:00+00:00\")) AS Date32) + IntervalDayTime(\"123\")\ - \n TableScan: test projection=None"; + \n TableScan: test"; let actual = get_optimized_plan_formatted(&plan, &time); assert_eq!(expected, actual); diff --git a/datafusion/optimizer/src/single_distinct_to_groupby.rs b/datafusion/optimizer/src/single_distinct_to_groupby.rs index 80214f302cb..82adc994f68 100644 --- a/datafusion/optimizer/src/single_distinct_to_groupby.rs +++ b/datafusion/optimizer/src/single_distinct_to_groupby.rs @@ -237,8 +237,9 @@ mod tests { .build()?; // Do nothing - let expected = "Aggregate: groupBy=[[]], aggr=[[MAX(#test.b)]] [MAX(test.b):UInt32;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + let expected = + "Aggregate: groupBy=[[]], aggr=[[MAX(#test.b)]] [MAX(test.b):UInt32;N]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -256,7 +257,7 @@ mod tests { let expected = "Projection: #COUNT(alias1) AS COUNT(DISTINCT test.b) [COUNT(DISTINCT test.b):Int64;N]\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(#alias1)]] [COUNT(alias1):Int64;N]\ \n Aggregate: groupBy=[[#test.b AS alias1]], aggr=[[]] [alias1:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -278,7 +279,7 @@ mod tests { // Should not be optimized let expected = "Aggregate: groupBy=[[GROUPING SETS ((#test.a), (#test.b))]], aggr=[[COUNT(DISTINCT #test.c)]] [a:UInt32, b:UInt32, COUNT(DISTINCT test.c):Int64;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -299,7 +300,7 @@ mod tests { // Should not be optimized let expected = "Aggregate: groupBy=[[CUBE (#test.a, #test.b)]], aggr=[[COUNT(DISTINCT #test.c)]] [a:UInt32, b:UInt32, COUNT(DISTINCT test.c):Int64;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -319,7 +320,7 @@ mod tests { // Should not be optimized let expected = "Aggregate: groupBy=[[ROLLUP (#test.a, #test.b)]], aggr=[[COUNT(DISTINCT #test.c)]] [a:UInt32, b:UInt32, COUNT(DISTINCT test.c):Int64;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -336,7 +337,7 @@ mod tests { let expected = "Projection: #COUNT(alias1) AS COUNT(DISTINCT Int32(2) * test.b) [COUNT(DISTINCT Int32(2) * test.b):Int64;N]\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(#alias1)]] [COUNT(alias1):Int64;N]\ \n Aggregate: groupBy=[[Int32(2) * #test.b AS alias1]], aggr=[[]] [alias1:Int32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -354,7 +355,7 @@ mod tests { let expected = "Projection: #test.a AS a, #COUNT(alias1) AS COUNT(DISTINCT test.b) [a:UInt32, COUNT(DISTINCT test.b):Int64;N]\ \n Aggregate: groupBy=[[#test.a]], aggr=[[COUNT(#alias1)]] [a:UInt32, COUNT(alias1):Int64;N]\ \n Aggregate: groupBy=[[#test.a, #test.b AS alias1]], aggr=[[]] [a:UInt32, alias1:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -373,7 +374,7 @@ mod tests { // Do nothing let expected = "Aggregate: groupBy=[[#test.a]], aggr=[[COUNT(DISTINCT #test.b), COUNT(DISTINCT #test.c)]] [a:UInt32, COUNT(DISTINCT test.b):Int64;N, COUNT(DISTINCT test.c):Int64;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -400,7 +401,7 @@ mod tests { let expected = "Projection: #test.a AS a, #COUNT(alias1) AS COUNT(DISTINCT test.b), #MAX(alias1) AS MAX(DISTINCT test.b) [a:UInt32, COUNT(DISTINCT test.b):Int64;N, MAX(DISTINCT test.b):UInt32;N]\ \n Aggregate: groupBy=[[#test.a]], aggr=[[COUNT(#alias1), MAX(#alias1)]] [a:UInt32, COUNT(alias1):Int64;N, MAX(alias1):UInt32;N]\ \n Aggregate: groupBy=[[#test.a, #test.b AS alias1]], aggr=[[]] [a:UInt32, alias1:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -419,7 +420,7 @@ mod tests { // Do nothing let expected = "Aggregate: groupBy=[[#test.a]], aggr=[[COUNT(DISTINCT #test.b), COUNT(#test.c)]] [a:UInt32, COUNT(DISTINCT test.b):Int64;N, COUNT(test.c):Int64;N]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) diff --git a/datafusion/optimizer/src/subquery_filter_to_join.rs b/datafusion/optimizer/src/subquery_filter_to_join.rs index 1a61f92df3d..e2622bf75d3 100644 --- a/datafusion/optimizer/src/subquery_filter_to_join.rs +++ b/datafusion/optimizer/src/subquery_filter_to_join.rs @@ -233,9 +233,9 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Semi Join: #test.c = #sq.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq.c [c:UInt32]\ - \n TableScan: sq projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -252,9 +252,9 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Anti Join: #test.c = #sq.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq.c [c:UInt32]\ - \n TableScan: sq projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -275,11 +275,11 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Semi Join: #test.b = #sq_2.c [a:UInt32, b:UInt32, c:UInt32]\ \n Semi Join: #test.c = #sq_1.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq_1.c [c:UInt32]\ - \n TableScan: sq_1 projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: sq_1 [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq_2.c [c:UInt32]\ - \n TableScan: sq_2 projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq_2 [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -303,9 +303,9 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Filter: #test.a = UInt32(1) AND #test.b < UInt32(30) [a:UInt32, b:UInt32, c:UInt32]\ \n Semi Join: #test.c = #sq.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq.c [c:UInt32]\ - \n TableScan: sq projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -330,8 +330,8 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Filter: #test.a = UInt32(1) AND #test.b < UInt32(30) OR #test.c IN (\ Subquery: Projection: #sq.c\ - \n TableScan: sq projection=None) [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq) [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -353,9 +353,9 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Filter: #test.a = UInt32(1) OR #test.b IN (Subquery: Projection: #sq1.c\ - \n TableScan: sq1 projection=None) AND #test.c IN (Subquery: Projection: #sq2.c\ - \n TableScan: sq2 projection=None) [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq1) AND #test.c IN (Subquery: Projection: #sq2.c\ + \n TableScan: sq2) [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -378,12 +378,12 @@ mod tests { let expected = "Projection: #test.b [b:UInt32]\ \n Semi Join: #test.b = #sq.a [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq.a [a:UInt32]\ \n Semi Join: #sq.a = #sq_nested.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: sq projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: sq [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq_nested.c [c:UInt32]\ - \n TableScan: sq_nested projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq_nested [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) @@ -407,12 +407,12 @@ mod tests { let expected = "Projection: #wrapped.b [b:UInt32]\ \n Filter: #wrapped.b < UInt32(30) OR #wrapped.c IN (\ Subquery: Projection: #sq_outer.c\ - \n TableScan: sq_outer projection=None) [b:UInt32, c:UInt32]\ + \n TableScan: sq_outer) [b:UInt32, c:UInt32]\ \n Projection: #test.b, #test.c, alias=wrapped [b:UInt32, c:UInt32]\ \n Semi Join: #test.c = #sq_inner.c [a:UInt32, b:UInt32, c:UInt32]\ - \n TableScan: test projection=None [a:UInt32, b:UInt32, c:UInt32]\ + \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\ \n Projection: #sq_inner.c [c:UInt32]\ - \n TableScan: sq_inner projection=None [a:UInt32, b:UInt32, c:UInt32]"; + \n TableScan: sq_inner [a:UInt32, b:UInt32, c:UInt32]"; assert_optimized_plan_eq(&plan, expected); Ok(()) diff --git a/datafusion/sql/README.md b/datafusion/sql/README.md index c451d4bbe72..9f40d53ed65 100644 --- a/datafusion/sql/README.md +++ b/datafusion/sql/README.md @@ -73,11 +73,11 @@ Sort: #state_tax DESC NULLS FIRST Inner Join: #c.id = #o.customer_id Inner Join: #c.state = #s.id SubqueryAlias: c - TableScan: customer projection=None + TableScan: customer SubqueryAlias: s - TableScan: state projection=None + TableScan: state SubqueryAlias: o - TableScan: orders projection=None + TableScan: orders ``` [df]: https://crates.io/crates/datafusion diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index d8df55d9ace..a20e3a0139f 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -2738,7 +2738,7 @@ mod tests { quick_test( "SELECT *, first_name AS fn from person", "Projection: #person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀, #person.first_name AS fn\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -2757,7 +2757,7 @@ mod tests { FROM person WHERE state = 'CO'"; let expected = "Projection: #person.id, #person.first_name, #person.last_name\ \n Filter: #person.state = Utf8(\"CO\")\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2781,7 +2781,7 @@ mod tests { FROM person WHERE NOT state"; let expected = "Projection: #person.id, #person.first_name, #person.last_name\ \n Filter: NOT #person.state\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2791,7 +2791,7 @@ mod tests { FROM person WHERE state = 'CO' AND age >= 21 AND age <= 65"; let expected = "Projection: #person.id, #person.first_name, #person.last_name\ \n Filter: #person.state = Utf8(\"CO\") AND #person.age >= Int64(21) AND #person.age <= Int64(65)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2802,7 +2802,7 @@ mod tests { let expected = "Projection: #person.state\ \n Filter: #person.birth_date < CAST(Int64(158412331400600000) AS Timestamp(Nanosecond, None))\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2814,7 +2814,7 @@ mod tests { let expected = "Projection: #person.state\ \n Filter: #person.birth_date < CAST(Utf8(\"2020-01-01\") AS Date32)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2836,7 +2836,7 @@ mod tests { AND #person.age >= Int64(21) \ AND #person.age < Int64(65) \ AND #person.age <= Int64(65)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2845,7 +2845,7 @@ mod tests { let sql = "SELECT state FROM person WHERE age BETWEEN 21 AND 65"; let expected = "Projection: #person.state\ \n Filter: #person.age BETWEEN Int64(21) AND Int64(65)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2855,7 +2855,7 @@ mod tests { let sql = "SELECT state FROM person WHERE age NOT BETWEEN 21 AND 65"; let expected = "Projection: #person.state\ \n Filter: #person.age NOT BETWEEN Int64(21) AND Int64(65)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2875,7 +2875,7 @@ mod tests { \n Projection: #a.fn1 AS fn2, #a.last_name, #a.birth_date, alias=b\ \n Projection: #a.fn1, #a.last_name, #a.birth_date, #a.age, alias=a\ \n Projection: #person.first_name AS fn1, #person.last_name, #person.birth_date, #person.age, alias=a\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2894,7 +2894,7 @@ mod tests { \n Projection: #a.fn1, #a.age, alias=a\ \n Projection: #person.first_name AS fn1, #person.age, alias=a\ \n Filter: #person.age > Int64(20)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2906,7 +2906,7 @@ mod tests { let expected = "Projection: #l.a, #l.b, #l.c\ \n Projection: #l.l_item_id AS a, #l.l_description AS b, #l.price AS c, alias=l\ \n SubqueryAlias: l\ - \n TableScan: lineitem projection=None"; + \n TableScan: lineitem"; quick_test(sql, expected); } @@ -2928,7 +2928,7 @@ mod tests { HAVING age > 100 AND age < 200"; let expected = "Projection: #person.id, #person.age\ \n Filter: #person.age > Int64(100) AND #person.age < Int64(200)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2978,7 +2978,7 @@ mod tests { let expected = "Projection: #MAX(person.age)\ \n Filter: #MAX(person.age) < Int64(30)\ \n Aggregate: groupBy=[[]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -2990,7 +2990,7 @@ mod tests { let expected = "Projection: #MAX(person.age)\ \n Filter: #MAX(person.first_name) > Utf8(\"M\")\ \n Aggregate: groupBy=[[]], aggr=[[MAX(#person.age), MAX(#person.first_name)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3017,7 +3017,7 @@ mod tests { let expected = "Projection: #MAX(person.age) AS max_age\ \n Filter: #MAX(person.age) < Int64(30)\ \n Aggregate: groupBy=[[]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3029,7 +3029,7 @@ mod tests { let expected = "Projection: #MAX(person.age) AS max_age\ \n Filter: #MAX(person.age) < Int64(30)\ \n Aggregate: groupBy=[[]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3042,7 +3042,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #person.first_name = Utf8(\"M\")\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3057,7 +3057,7 @@ mod tests { \n Filter: #MAX(person.age) < Int64(100)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ \n Filter: #person.id > Int64(5)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3073,7 +3073,7 @@ mod tests { \n Filter: #MAX(person.age) < Int64(100)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ \n Filter: #person.id > Int64(5) AND #person.age > Int64(18)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3086,7 +3086,7 @@ mod tests { let expected = "Projection: #person.first_name AS fn, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(2) AND #person.first_name = Utf8(\"M\")\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3100,7 +3100,7 @@ mod tests { let expected = "Projection: #person.first_name AS fn, #MAX(person.age) AS max_age\ \n Filter: #MAX(person.age) > Int64(2) AND #MAX(person.age) < Int64(5) AND #person.first_name = Utf8(\"M\") AND #person.first_name = Utf8(\"N\")\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3113,7 +3113,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(100)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3141,7 +3141,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(100) AND #MAX(person.age) < Int64(200)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3154,7 +3154,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(100) AND #MIN(person.id) < Int64(50)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age), MIN(#person.id)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3168,7 +3168,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age) AS max_age\ \n Filter: #MAX(person.age) > Int64(100)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3183,7 +3183,7 @@ mod tests { "Projection: #person.first_name, #MAX(person.age) + Int64(1) AS max_age_plus_one\ \n Filter: #MAX(person.age) + Int64(1) > Int64(100)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3197,7 +3197,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(100) AND #MIN(person.id - Int64(2)) < Int64(50)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age), MIN(#person.id - Int64(2))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3210,7 +3210,7 @@ mod tests { let expected = "Projection: #person.first_name, #MAX(person.age)\ \n Filter: #MAX(person.age) > Int64(100) AND #COUNT(UInt8(1)) < Int64(50)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.age), COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3218,7 +3218,7 @@ mod tests { fn select_binary_expr() { let sql = "SELECT age + salary from person"; let expected = "Projection: #person.age + #person.salary\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3226,7 +3226,7 @@ mod tests { fn select_binary_expr_nested() { let sql = "SELECT (age + salary)/2 from person"; let expected = "Projection: #person.age + #person.salary / Int64(2)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3236,7 +3236,7 @@ mod tests { r#"SELECT * FROM person GROUP BY id, first_name, last_name, age, state, salary, birth_date, "😀""#, "Projection: #person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀\ \n Aggregate: groupBy=[[#person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀]], aggr=[[]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); quick_test( "SELECT * FROM (SELECT first_name, last_name FROM person) AS a GROUP BY first_name, last_name", @@ -3244,7 +3244,7 @@ mod tests { \n Aggregate: groupBy=[[#a.first_name, #a.last_name]], aggr=[[]]\ \n Projection: #a.first_name, #a.last_name, alias=a\ \n Projection: #person.first_name, #person.last_name, alias=a\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3254,7 +3254,7 @@ mod tests { "SELECT MIN(age) FROM person", "Projection: #MIN(person.age)\ \n Aggregate: groupBy=[[]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3264,7 +3264,7 @@ mod tests { "SELECT SUM(age) from person", "Projection: #SUM(person.age)\ \n Aggregate: groupBy=[[]], aggr=[[SUM(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3291,7 +3291,7 @@ mod tests { "SELECT MIN(age), MIN(age) AS a FROM person", "Projection: #MIN(person.age), #MIN(person.age) AS a\ \n Aggregate: groupBy=[[]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3301,7 +3301,7 @@ mod tests { "SELECT MIN(age) AS a, MIN(age) AS b FROM person", "Projection: #MIN(person.age) AS a, #MIN(person.age) AS b\ \n Aggregate: groupBy=[[]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3321,7 +3321,7 @@ mod tests { "SELECT state, MIN(age), MAX(age) FROM person GROUP BY state", "Projection: #person.state, #MIN(person.age), #MAX(person.age)\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age), MAX(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3331,7 +3331,7 @@ mod tests { "SELECT state AS a, MIN(age) AS b FROM person GROUP BY state", "Projection: #person.state AS a, #MIN(person.age) AS b\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3351,7 +3351,7 @@ mod tests { "SELECT MIN(age), MAX(age) FROM person GROUP BY state", "Projection: #MIN(person.age), #MAX(person.age)\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age), MAX(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3409,7 +3409,7 @@ mod tests { "SELECT MAX(first_name) FROM person GROUP BY first_name", "Projection: #MAX(person.first_name)\ \n Aggregate: groupBy=[[#person.first_name]], aggr=[[MAX(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3419,13 +3419,13 @@ mod tests { "SELECT state, age AS b, COUNT(1) FROM person GROUP BY 1, 2", "Projection: #person.state, #person.age AS b, #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.state, #person.age]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); quick_test( "SELECT state, age AS b, COUNT(1) FROM person GROUP BY 2, 1", "Projection: #person.state, #person.age AS b, #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.age, #person.state]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3452,7 +3452,7 @@ mod tests { "SELECT state AS a, MIN(age) AS b FROM person GROUP BY a", "Projection: #person.state AS a, #MIN(person.age) AS b\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3472,7 +3472,7 @@ mod tests { "SELECT state, MIN(age), MIN(age) AS ma FROM person GROUP BY state", "Projection: #person.state, #MIN(person.age), #MIN(person.age) AS ma\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ) } @@ -3482,7 +3482,7 @@ mod tests { "SELECT MIN(first_name) FROM person GROUP BY age + 1", "Projection: #MIN(person.first_name)\ \n Aggregate: groupBy=[[#person.age + Int64(1)]], aggr=[[MIN(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3493,13 +3493,13 @@ mod tests { "SELECT age + 1, MIN(first_name) FROM person GROUP BY age + 1", "Projection: #person.age + Int64(1), #MIN(person.first_name)\ \n Aggregate: groupBy=[[#person.age + Int64(1)]], aggr=[[MIN(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); quick_test( "SELECT MIN(first_name), age + 1 FROM person GROUP BY age + 1", "Projection: #MIN(person.first_name), #person.age + Int64(1)\ \n Aggregate: groupBy=[[#person.age + Int64(1)]], aggr=[[MIN(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3510,7 +3510,7 @@ mod tests { "SELECT ((age + 1) / 2) * (age + 1), MIN(first_name) FROM person GROUP BY age + 1", "Projection: #person.age + Int64(1) / Int64(2) * #person.age + Int64(1), #MIN(person.first_name)\ \n Aggregate: groupBy=[[#person.age + Int64(1)]], aggr=[[MIN(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3543,7 +3543,7 @@ mod tests { "SELECT state, MIN(age) < 10 FROM person GROUP BY state", "Projection: #person.state, #MIN(person.age) < Int64(10)\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3553,7 +3553,7 @@ mod tests { "SELECT age + 1, MAX(first_name) FROM person GROUP BY age", "Projection: #person.age + Int64(1), #MAX(person.first_name)\ \n Aggregate: groupBy=[[#person.age]], aggr=[[MAX(#person.first_name)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3563,7 +3563,7 @@ mod tests { "SELECT age + MIN(salary) FROM person GROUP BY age", "Projection: #person.age + #MIN(person.salary)\ \n Aggregate: groupBy=[[#person.age]], aggr=[[MIN(#person.salary)]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3573,7 +3573,7 @@ mod tests { "SELECT state, MIN(age + 1) FROM person GROUP BY state", "Projection: #person.state, #MIN(person.age + Int64(1))\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MIN(#person.age + Int64(1))]]\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3582,7 +3582,7 @@ mod tests { quick_test( "SELECT * from person", "Projection: #person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3591,7 +3591,7 @@ mod tests { let sql = "SELECT COUNT(1) FROM person"; let expected = "Projection: #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3600,7 +3600,7 @@ mod tests { let sql = "SELECT COUNT(id) FROM person"; let expected = "Projection: #COUNT(person.id)\ \n Aggregate: groupBy=[[]], aggr=[[COUNT(#person.id)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3609,7 +3609,7 @@ mod tests { let sql = "SELECT approx_median(age) FROM person"; let expected = "Projection: #APPROXPERCENTILECONT(person.age,Float64(0.5))\ \n Aggregate: groupBy=[[]], aggr=[[APPROXPERCENTILECONT(#person.age, Float64(0.5))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3617,7 +3617,7 @@ mod tests { fn select_scalar_func() { let sql = "SELECT sqrt(age) FROM person"; let expected = "Projection: sqrt(#person.age)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3625,7 +3625,7 @@ mod tests { fn select_aliased_scalar_func() { let sql = "SELECT sqrt(person.age) AS square_people FROM person"; let expected = "Projection: sqrt(#person.age) AS square_people\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3635,7 +3635,7 @@ mod tests { FROM aggregate_test_100 WHERE c3/nullif(c4+c5, 0) > 0.1"; let expected = "Projection: #aggregate_test_100.c3 / #aggregate_test_100.c4 + #aggregate_test_100.c5\ \n Filter: #aggregate_test_100.c3 / nullif(#aggregate_test_100.c4 + #aggregate_test_100.c5, Int64(0)) > Float64(0.1)\ - \n TableScan: aggregate_test_100 projection=None"; + \n TableScan: aggregate_test_100"; quick_test(sql, expected); } @@ -3644,7 +3644,7 @@ mod tests { let sql = "SELECT c3 FROM aggregate_test_100 WHERE c3 > -0.1 AND -c4 > 0"; let expected = "Projection: #aggregate_test_100.c3\ \n Filter: #aggregate_test_100.c3 > Float64(-0.1) AND (- #aggregate_test_100.c4) > Int64(0)\ - \n TableScan: aggregate_test_100 projection=None"; + \n TableScan: aggregate_test_100"; quick_test(sql, expected); } @@ -3653,7 +3653,7 @@ mod tests { let sql = "SELECT c3 FROM aggregate_test_100 WHERE c3 > +0.1 AND +c4 > 0"; let expected = "Projection: #aggregate_test_100.c3\ \n Filter: #aggregate_test_100.c3 > Float64(0.1) AND #aggregate_test_100.c4 > Int64(0)\ - \n TableScan: aggregate_test_100 projection=None"; + \n TableScan: aggregate_test_100"; quick_test(sql, expected); } @@ -3662,7 +3662,7 @@ mod tests { let sql = "SELECT id FROM person ORDER BY 1"; let expected = "Sort: #person.id ASC NULLS LAST\ \n Projection: #person.id\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3672,7 +3672,7 @@ mod tests { let sql = "SELECT id, state, age FROM person ORDER BY 1, 3"; let expected = "Sort: #person.id ASC NULLS LAST, #person.age ASC NULLS LAST\ \n Projection: #person.id, #person.state, #person.age\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3702,7 +3702,7 @@ mod tests { let sql = "SELECT id FROM person ORDER BY id"; let expected = "Sort: #person.id ASC NULLS LAST\ \n Projection: #person.id\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3711,7 +3711,7 @@ mod tests { let sql = "SELECT id FROM person ORDER BY id DESC"; let expected = "Sort: #person.id DESC NULLS FIRST\ \n Projection: #person.id\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3721,14 +3721,14 @@ mod tests { "SELECT id FROM person ORDER BY id DESC NULLS LAST", "Sort: #person.id DESC NULLS LAST\ \n Projection: #person.id\ - \n TableScan: person projection=None", + \n TableScan: person", ); quick_test( "SELECT id FROM person ORDER BY id NULLS LAST", "Sort: #person.id ASC NULLS LAST\ \n Projection: #person.id\ - \n TableScan: person projection=None", + \n TableScan: person", ); } @@ -3737,7 +3737,7 @@ mod tests { let sql = "SELECT state FROM person GROUP BY state"; let expected = "Projection: #person.state\ \n Aggregate: groupBy=[[#person.state]], aggr=[[]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3747,7 +3747,7 @@ mod tests { let sql = "SELECT MAX(age) FROM person GROUP BY state"; let expected = "Projection: #MAX(person.age)\ \n Aggregate: groupBy=[[#person.state]], aggr=[[MAX(#person.age)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3757,7 +3757,7 @@ mod tests { let sql = "SELECT state, COUNT(*) FROM person GROUP BY state"; let expected = "Projection: #person.state, #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.state]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3768,7 +3768,7 @@ mod tests { let expected = "\ Projection: #COUNT(person.state), #person.state\ \n Aggregate: groupBy=[[#person.state]], aggr=[[COUNT(#person.state)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3778,7 +3778,7 @@ mod tests { let sql = "SELECT c1, MIN(c12) FROM aggregate_test_100 GROUP BY c1, c13"; let expected = "Projection: #aggregate_test_100.c1, #MIN(aggregate_test_100.c12)\ \n Aggregate: groupBy=[[#aggregate_test_100.c1, #aggregate_test_100.c13]], aggr=[[MIN(#aggregate_test_100.c12)]]\ - \n TableScan: aggregate_test_100 projection=None"; + \n TableScan: aggregate_test_100"; quick_test(sql, expected); } @@ -3834,8 +3834,8 @@ mod tests { ON id = customer_id"; let expected = "Projection: #person.id, #orders.order_id\ \n Inner Join: #person.id = #orders.customer_id\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -3846,9 +3846,10 @@ mod tests { JOIN orders \ ON id = customer_id AND order_id > 1 "; let expected = "Projection: #person.id, #orders.order_id\ - \n Inner Join: #person.id = #orders.customer_id Filter: #orders.order_id > Int64(1)\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n Inner Join: #person.id = #orders.customer_id Filter: #orders.order_id > Int64(1)\ + \n TableScan: person\ + \n TableScan: orders"; + quick_test(sql, expected); } @@ -3859,9 +3860,9 @@ mod tests { LEFT JOIN orders \ ON id = customer_id AND order_id > 1 AND age < 30"; let expected = "Projection: #person.id, #orders.order_id\ - \n Left Join: #person.id = #orders.customer_id Filter: #orders.order_id > Int64(1) AND #person.age < Int64(30)\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n Left Join: #person.id = #orders.customer_id Filter: #orders.order_id > Int64(1) AND #person.age < Int64(30)\ + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -3872,9 +3873,9 @@ mod tests { RIGHT JOIN orders \ ON id = customer_id AND id > 1 AND order_id < 100"; let expected = "Projection: #person.id, #orders.order_id\ - \n Right Join: #person.id = #orders.customer_id Filter: #person.id > Int64(1) AND #orders.order_id < Int64(100)\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n Right Join: #person.id = #orders.customer_id Filter: #person.id > Int64(1) AND #orders.order_id < Int64(100)\ + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -3886,8 +3887,8 @@ mod tests { ON id = customer_id AND id > 1 AND order_id < 100"; let expected = "Projection: #person.id, #orders.order_id\ \n Full Join: #person.id = #orders.customer_id Filter: #person.id > Int64(1) AND #orders.order_id < Int64(100)\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -3899,8 +3900,8 @@ mod tests { ON person.id = orders.customer_id"; let expected = "Projection: #person.id, #orders.order_id\ \n Inner Join: #person.id = #orders.customer_id\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -3912,9 +3913,9 @@ mod tests { USING (id)"; let expected = "Projection: #person.first_name, #person.id\ \n Inner Join: Using #person.id = #person2.id\ - \n TableScan: person projection=None\ + \n TableScan: person\ \n SubqueryAlias: person2\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -3926,9 +3927,9 @@ mod tests { USING (l_item_id)"; let expected = "Projection: #lineitem.l_item_id, #lineitem.l_description, #lineitem.price, #lineitem2.l_description, #lineitem2.price\ \n Inner Join: Using #lineitem.l_item_id = #lineitem2.l_item_id\ - \n TableScan: lineitem projection=None\ + \n TableScan: lineitem\ \n SubqueryAlias: lineitem2\ - \n TableScan: lineitem projection=None"; + \n TableScan: lineitem"; quick_test(sql, expected); } @@ -3942,9 +3943,9 @@ mod tests { "Projection: #person.id, #orders.order_id, #lineitem.l_description\ \n Inner Join: #orders.o_item_id = #lineitem.l_item_id\ \n Inner Join: #person.id = #orders.customer_id\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None\ - \n TableScan: lineitem projection=None"; + \n TableScan: person\ + \n TableScan: orders\ + \n TableScan: lineitem"; quick_test(sql, expected); } @@ -3955,7 +3956,7 @@ mod tests { WHERE delivered = false OR delivered = true"; let expected = "Projection: #orders.order_id\ \n Filter: #orders.delivered = Boolean(false) OR #orders.delivered = Boolean(true)\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -3965,9 +3966,9 @@ mod tests { let expected = "Projection: #order_id\ \n Aggregate: groupBy=[[#order_id]], aggr=[[]]\ \n Union\n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -3976,9 +3977,9 @@ mod tests { let sql = "SELECT order_id from orders UNION ALL SELECT order_id FROM orders"; let expected = "Union\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -3990,13 +3991,13 @@ mod tests { UNION ALL SELECT order_id FROM orders"; let expected = "Union\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4005,9 +4006,9 @@ mod tests { let sql = "SELECT order_id from orders UNION ALL SELECT customer_id FROM orders"; let expected = "Union\ \n Projection: #orders.order_id\ - \n TableScan: orders projection=None\ + \n TableScan: orders\ \n Projection: #orders.customer_id\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4041,7 +4042,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.order_id)\ \n WindowAggr: windowExpr=[[MAX(#orders.order_id)]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4051,7 +4052,7 @@ mod tests { let expected = "\ Projection: #orders.order_id AS oid, #MAX(orders.order_id) AS max_oid\ \n WindowAggr: windowExpr=[[MAX(#orders.order_id)]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4061,7 +4062,7 @@ mod tests { let expected = "\ Projection: #orders.order_id AS oid, #MAX(orders.order_id) AS max_oid, #MAX(orders.order_id) AS max_oid_dup\ \n WindowAggr: windowExpr=[[MAX(#orders.order_id)]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4072,7 +4073,7 @@ mod tests { Projection: #orders.order_id AS oid, #MAX(orders.order_id), #MAX(orders.order_id) ORDER BY [#orders.order_id ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MAX(#orders.order_id)]]\ \n WindowAggr: windowExpr=[[MAX(#orders.order_id) ORDER BY [#orders.order_id ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4082,7 +4083,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.qty * Float64(1.1))\ \n WindowAggr: windowExpr=[[MAX(#orders.qty * Float64(1.1))]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4093,7 +4094,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.qty), #MIN(orders.qty), #AVG(orders.qty)\ \n WindowAggr: windowExpr=[[MAX(#orders.qty), MIN(#orders.qty), AVG(#orders.qty)]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4112,7 +4113,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.qty) PARTITION BY [#orders.order_id]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) PARTITION BY [#orders.order_id]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4135,7 +4136,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST], #MIN(orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4146,7 +4147,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING, #MIN(orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4157,7 +4158,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW, #MIN(orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4200,7 +4201,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW, #MIN(orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id DESC NULLS FIRST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4223,7 +4224,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST], #MIN(orders.qty) ORDER BY [#orders.order_id + Int64(1) ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id + Int64(1) ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4248,7 +4249,7 @@ mod tests { \n WindowAggr: windowExpr=[[SUM(#orders.qty)]]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.qty ASC NULLS LAST, #orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST, #orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4273,7 +4274,7 @@ mod tests { \n WindowAggr: windowExpr=[[SUM(#orders.qty)]]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST, #orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4302,7 +4303,7 @@ mod tests { \n WindowAggr: windowExpr=[[SUM(#orders.qty)]]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) ORDER BY [#orders.qty ASC NULLS LAST, #orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) ORDER BY [#orders.order_id ASC NULLS LAST, #orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4322,7 +4323,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.qty) PARTITION BY [#orders.order_id] ORDER BY [#orders.qty ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) PARTITION BY [#orders.order_id] ORDER BY [#orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4342,7 +4343,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #MAX(orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.qty ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4366,7 +4367,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.qty ASC NULLS LAST], #MIN(orders.qty) PARTITION BY [#orders.qty] ORDER BY [#orders.order_id ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) PARTITION BY [#orders.qty] ORDER BY [#orders.order_id ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.qty ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4389,7 +4390,7 @@ mod tests { Projection: #orders.order_id, #MAX(orders.qty) PARTITION BY [#orders.order_id] ORDER BY [#orders.qty ASC NULLS LAST], #MIN(orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.price ASC NULLS LAST]\ \n WindowAggr: windowExpr=[[MAX(#orders.qty) PARTITION BY [#orders.order_id] ORDER BY [#orders.qty ASC NULLS LAST]]]\ \n WindowAggr: windowExpr=[[MIN(#orders.qty) PARTITION BY [#orders.order_id, #orders.qty] ORDER BY [#orders.price ASC NULLS LAST]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4400,7 +4401,7 @@ mod tests { let expected = "\ Projection: #orders.order_id, #APPROXPERCENTILECONT(orders.qty,Float64(0.5)) PARTITION BY [#orders.order_id]\ \n WindowAggr: windowExpr=[[APPROXPERCENTILECONT(#orders.qty, Float64(0.5)) PARTITION BY [#orders.order_id]]]\ - \n TableScan: orders projection=None"; + \n TableScan: orders"; quick_test(sql, expected); } @@ -4408,7 +4409,7 @@ mod tests { fn select_typedstring() { let sql = "SELECT date '2020-12-10' AS date FROM person"; let expected = "Projection: CAST(Utf8(\"2020-12-10\") AS Date32) AS date\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4416,7 +4417,7 @@ mod tests { fn select_multibyte_column() { let sql = r#"SELECT "😀" FROM person"#; let expected = "Projection: #person.😀\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4532,7 +4533,7 @@ mod tests { fn select_partially_qualified_column() { let sql = r#"SELECT person.first_name FROM public.person"#; let expected = "Projection: #public.person.first_name\ - \n TableScan: public.person projection=None"; + \n TableScan: public.person"; quick_test(sql, expected); } @@ -4542,9 +4543,9 @@ mod tests { let expected = "Projection: #person.id\ \n Inner Join: #lineitem.l_description = #orders.o_item_id\ \n Inner Join: #person.id = #lineitem.l_item_id\ - \n TableScan: person projection=None\ - \n TableScan: lineitem projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: lineitem\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -4555,9 +4556,9 @@ mod tests { \n Filter: #person.id = #person.age\ \n CrossJoin:\ \n CrossJoin:\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None\ - \n TableScan: lineitem projection=None"; + \n TableScan: person\ + \n TableScan: orders\ + \n TableScan: lineitem"; quick_test(sql, expected); } @@ -4567,9 +4568,9 @@ mod tests { let expected = "Projection: #peeps.id, #folks.first_name\ \n Inner Join: #peeps.id = #folks.id\ \n SubqueryAlias: peeps\ - \n TableScan: person projection=None\ + \n TableScan: person\ \n SubqueryAlias: folks\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4585,7 +4586,7 @@ mod tests { fn date_plus_interval_in_projection() { let sql = "select t_date32 + interval '5 days' FROM test"; let expected = "Projection: #test.t_date32 + IntervalDayTime(\"21474836480\")\ - \n TableScan: test projection=None"; + \n TableScan: test"; quick_test(sql, expected); } @@ -4598,7 +4599,7 @@ mod tests { let expected = "Projection: #test.t_date64\ \n Filter: #test.t_date64 BETWEEN CAST(Utf8(\"1999-12-31\") AS Date32) AND CAST(Utf8(\"1999-12-31\") AS Date32) + IntervalDayTime(\"128849018880\")\ - \n TableScan: test projection=None"; + \n TableScan: test"; quick_test(sql, expected); } @@ -4611,13 +4612,13 @@ mod tests { let subquery_expected = "Subquery: Projection: #person.first_name\ \n Filter: #person.last_name = #p.last_name AND #person.state = #p.state\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #p.id\ \n Filter: EXISTS ({})\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4636,17 +4637,17 @@ mod tests { let subquery_expected = "Subquery: Projection: #person.first_name\ \n Filter: #person.last_name = #p.last_name AND #person.state = #p.state\ \n Inner Join: #person.id = #p2.id\ - \n TableScan: person projection=None\ + \n TableScan: person\ \n SubqueryAlias: p2\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #person.id\ \n Filter: EXISTS ({})\ \n Inner Join: #person.id = #p.id\ - \n TableScan: person projection=None\ + \n TableScan: person\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4662,13 +4663,13 @@ mod tests { let subquery_expected = "Subquery: Projection: #person.id, #person.first_name, \ #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀\ \n Filter: #person.last_name = #p.last_name AND #person.state = #p.state\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #p.id\ \n Filter: EXISTS ({})\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4680,13 +4681,13 @@ mod tests { (SELECT id FROM person)"; let subquery_expected = "Subquery: Projection: #person.id\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #p.id\ \n Filter: #p.id IN ({})\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4699,13 +4700,13 @@ mod tests { let subquery_expected = "Subquery: Projection: #person.id\ \n Filter: #person.last_name = #p.last_name AND #person.state = Utf8(\"CO\")\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #p.id\ \n Filter: #p.id NOT IN ({})\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4718,12 +4719,12 @@ mod tests { let subquery_expected = "Subquery: Projection: #MAX(person.id)\ \n Aggregate: groupBy=[[]], aggr=[[MAX(#person.id)]]\ \n Filter: #person.last_name = #p.last_name\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!( "Projection: #p.id, ({})\ \n SubqueryAlias: p\ - \n TableScan: person projection=None", + \n TableScan: person", subquery_expected ); quick_test(sql, &expected); @@ -4743,15 +4744,15 @@ mod tests { \n Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\ \n Filter: #j2.j2_id = #j1.j1_id\ \n Inner Join: #j1.j1_id = #j3.j3_id\ - \n TableScan: j1 projection=None\ - \n TableScan: j3 projection=None"; + \n TableScan: j1\ + \n TableScan: j3"; let expected = format!( "Projection: #j1.j1_string, #j2.j2_string\ \n Filter: #j1.j1_id = #j2.j2_id - Int64(1) AND #j2.j2_id < ({})\ \n CrossJoin:\ - \n TableScan: j1 projection=None\ - \n TableScan: j2 projection=None", + \n TableScan: j1\ + \n TableScan: j2", subquery ); @@ -4767,11 +4768,11 @@ mod tests { let subquery = "Subquery: Projection: #cte.id, #cte.first_name, #cte.last_name, #cte.age, #cte.state, #cte.salary, #cte.birth_date, #cte.😀\ \n Filter: #cte.id = #person.id\ \n Projection: #person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀, alias=cte\ - \n TableScan: person projection=None"; + \n TableScan: person"; let expected = format!("Projection: #person.id, #person.first_name, #person.last_name, #person.age, #person.state, #person.salary, #person.birth_date, #person.😀\ \n Filter: EXISTS ({})\ - \n TableScan: person projection=None", subquery); + \n TableScan: person", subquery); quick_test(sql, &expected) } @@ -4781,7 +4782,7 @@ mod tests { let sql = "SELECT id, state, age, COUNT(*) FROM person GROUP BY id, ROLLUP (state, age)"; let expected = "Projection: #person.id, #person.state, #person.age, #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.id, ROLLUP (#person.state, #person.age)]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4791,7 +4792,7 @@ mod tests { FROM person GROUP BY id, ROLLUP (state, age)"; let expected = "Projection: #person.id, #person.state, #person.age, #GROUPING(person.state), #GROUPING(person.age), #GROUPING(person.state) + #GROUPING(person.age), #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.id, ROLLUP (#person.state, #person.age)]], aggr=[[GROUPING(#person.state), GROUPING(#person.age), COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4813,7 +4814,7 @@ mod tests { let expected = "Projection: #SUM(person.age) AS total_sum, #person.state, #person.last_name, #GROUPING(person.state) + #GROUPING(person.last_name) AS x, #RANK() PARTITION BY [#GROUPING(person.state) + #GROUPING(person.last_name), CASE WHEN #GROUPING(person.last_name) = Int64(0) THEN #person.state END] ORDER BY [#SUM(person.age) DESC NULLS FIRST] AS the_rank\ \n WindowAggr: windowExpr=[[RANK() PARTITION BY [#GROUPING(person.state) + #GROUPING(person.last_name), CASE WHEN #GROUPING(person.last_name) = Int64(0) THEN #person.state END] ORDER BY [#SUM(person.age) DESC NULLS FIRST]]]\ \n Aggregate: groupBy=[[ROLLUP (#person.state, #person.last_name)]], aggr=[[SUM(#person.age), GROUPING(#person.state), GROUPING(#person.last_name)]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4823,7 +4824,7 @@ mod tests { "SELECT id, state, age, COUNT(*) FROM person GROUP BY id, CUBE (state, age)"; let expected = "Projection: #person.id, #person.state, #person.age, #COUNT(UInt8(1))\ \n Aggregate: groupBy=[[#person.id, CUBE (#person.state, #person.age)]], aggr=[[COUNT(UInt8(1))]]\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4831,7 +4832,7 @@ mod tests { async fn round_decimal() { let sql = "SELECT round(price/3, 2) FROM test_decimal"; let expected = "Projection: round(#test_decimal.price / Int64(3), Int64(2))\ - \n TableScan: test_decimal projection=None"; + \n TableScan: test_decimal"; quick_test(sql, expected); } @@ -4851,8 +4852,8 @@ mod tests { let expected = "Projection: #person.id, #orders.order_id\ \n Filter: #person.id = #orders.customer_id OR #person.age > Int64(30)\ \n CrossJoin:\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -4863,8 +4864,8 @@ mod tests { JOIN orders ON id = customer_id AND (person.age > 30 OR person.last_name = 'X')"; let expected = "Projection: #person.id, #orders.order_id\ \n Inner Join: #person.id = #orders.customer_id Filter: #person.age > Int64(30) OR #person.last_name = Utf8(\"X\")\ - \n TableScan: person projection=None\ - \n TableScan: orders projection=None"; + \n TableScan: person\ + \n TableScan: orders"; quick_test(sql, expected); } @@ -4874,7 +4875,7 @@ mod tests { let expected = "Limit: skip=0, fetch=5\ \n Projection: #person.id\ \n Filter: #person.id > Int64(100)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); // Flip the order of LIMIT and OFFSET in the query. Plan should remain the same. @@ -4888,7 +4889,7 @@ mod tests { let expected = "Limit: skip=5, fetch=None\ \n Projection: #person.id\ \n Filter: #person.id > Int64(100)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4898,7 +4899,7 @@ mod tests { let expected = "Limit: skip=3, fetch=5\ \n Projection: #person.id\ \n Filter: #person.id > Int64(100)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); } @@ -4908,7 +4909,7 @@ mod tests { let expected = "Limit: skip=3, fetch=5\ \n Projection: #person.id\ \n Filter: #person.id > Int64(100)\ - \n TableScan: person projection=None"; + \n TableScan: person"; quick_test(sql, expected); }