Skip to content

Apache DataFusion SQL Query Engine

fix: remove trailing whitespace in `Display` for `LogicalPlan::Projection` (#16164)

Atahan Yorgancıc5df6eee106d
diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs
index 3c7d85ef87..87e354959f 100644
--- a/datafusion/core/tests/sql/explain_analyze.rs
+++ b/datafusion/core/tests/sql/explain_analyze.rs
@@ -784,7 +784,7 @@ async fn explain_logical_plan_only() {
vec!["logical_plan", "Projection: count(Int64(1)) AS count(*)\
\n Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]\
\n SubqueryAlias: t\
- \n Projection: \
+ \n Projection:\
\n Values: (Utf8(\"a\"), Int64(1), Int64(100)), (Utf8(\"a\"), Int64(2), Int64(150))"]];
assert_eq!(expected, actual);
}
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index db6d2cd12d..7b47b59256 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -1815,12 +1815,12 @@ impl LogicalPlan {
Ok(())
}
LogicalPlan::Projection(Projection { ref expr, .. }) => {
- write!(f, "Projection: ")?;
+ write!(f, "Projection:")?;
for (i, expr_item) in expr.iter().enumerate() {
if i > 0 {
- write!(f, ", ")?;
+ write!(f, ",")?;
}
- write!(f, "{expr_item}")?;
+ write!(f, " {expr_item}")?;
}
Ok(())
}
diff --git a/datafusion/optimizer/src/optimize_projections/mod.rs b/datafusion/optimizer/src/optimize_projections/mod.rs
index 1093c0b3cf..926315eb86 100644
--- a/datafusion/optimizer/src/optimize_projections/mod.rs
+++ b/datafusion/optimizer/src/optimize_projections/mod.rs
@@ -1124,7 +1124,7 @@ mod tests {
plan,
@r"
Aggregate: groupBy=[[]], aggr=[[count(Int32(1))]]
- Projection:
+ Projection:
Aggregate: groupBy=[[]], aggr=[[count(Int32(1))]]
TableScan: ?table? projection=[]
"
diff --git a/datafusion/optimizer/tests/optimizer_integration.rs b/datafusion/optimizer/tests/optimizer_integration.rs
index 877e15992f..95a9db6c8a 100644
--- a/datafusion/optimizer/tests/optimizer_integration.rs
+++ b/datafusion/optimizer/tests/optimizer_integration.rs
@@ -250,7 +250,7 @@ fn between_date32_plus_interval() -> Result<()> {
format!("{plan}"),
@r#"
Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
- Projection:
+ Projection:
Filter: test.col_date32 >= Date32("1998-03-18") AND test.col_date32 <= Date32("1998-06-16")
TableScan: test projection=[col_date32]
"#
@@ -268,7 +268,7 @@ fn between_date64_plus_interval() -> Result<()> {
format!("{plan}"),
@r#"
Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
- Projection:
+ Projection:
Filter: test.col_date64 >= Date64("1998-03-18") AND test.col_date64 <= Date64("1998-06-16")
TableScan: test projection=[col_date64]
"#
diff --git a/datafusion/sqllogictest/test_files/array.slt b/datafusion/sqllogictest/test_files/array.slt
index 9bbae2390d..d89ba600d7 100644
--- a/datafusion/sqllogictest/test_files/array.slt
+++ b/datafusion/sqllogictest/test_files/array.slt
@@ -6022,7 +6022,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])
07)------------TableScan: tmp_table projection=[value]
physical_plan
@@ -6051,7 +6051,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])
07)------------TableScan: tmp_table projection=[value]
physical_plan
@@ -6080,7 +6080,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])
07)------------TableScan: tmp_table projection=[value]
physical_plan
@@ -6111,7 +6111,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: array_has(LargeList([7f4b18de3cfeb9b4ac78c381ee2ad278, a, b, c]), substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)))
07)------------TableScan: tmp_table projection=[value]
physical_plan
@@ -6140,7 +6140,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])
07)------------TableScan: tmp_table projection=[value]
physical_plan
@@ -6171,7 +6171,7 @@ logical_plan
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: test
04)------SubqueryAlias: t
-05)--------Projection:
+05)--------Projection:
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8)) AS Utf8), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL)
07)------------TableScan: tmp_table projection=[value]
physical_plan
diff --git a/datafusion/sqllogictest/test_files/explain.slt b/datafusion/sqllogictest/test_files/explain.slt
index 6227a76455..2df8a9dfba 100644
--- a/datafusion/sqllogictest/test_files/explain.slt
+++ b/datafusion/sqllogictest/test_files/explain.slt
@@ -420,7 +420,7 @@ logical_plan
01)LeftSemi Join:
02)--TableScan: t1 projection=[a]
03)--SubqueryAlias: __correlated_sq_1
-04)----Projection:
+04)----Projection:
05)------Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
06)--------TableScan: t2 projection=[]
physical_plan
diff --git a/datafusion/sqllogictest/test_files/joins.slt b/datafusion/sqllogictest/test_files/joins.slt
index ddf701ba04..b5189d16ec 100644
--- a/datafusion/sqllogictest/test_files/joins.slt
+++ b/datafusion/sqllogictest/test_files/joins.slt
@@ -4385,7 +4385,7 @@ JOIN my_catalog.my_schema.table_with_many_types AS r ON l.binary_col = r.binary_
logical_plan
01)Projection: count(Int64(1)) AS count(*)
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
-03)----Projection:
+03)----Projection:
04)------Inner Join: l.binary_col = r.binary_col
05)--------SubqueryAlias: l
06)----------TableScan: my_catalog.my_schema.table_with_many_types projection=[binary_col]
diff --git a/datafusion/sqllogictest/test_files/limit.slt b/datafusion/sqllogictest/test_files/limit.slt
index 93ffa313b8..2f8944f462 100644
--- a/datafusion/sqllogictest/test_files/limit.slt
+++ b/datafusion/sqllogictest/test_files/limit.slt
@@ -365,7 +365,7 @@ EXPLAIN SELECT COUNT(*) FROM (SELECT a FROM t1 WHERE a > 3 LIMIT 3 OFFSET 6);
logical_plan
01)Projection: count(Int64(1)) AS count(*)
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
-03)----Projection:
+03)----Projection:
04)------Limit: skip=6, fetch=3
05)--------Filter: t1.a > Int32(3)
06)----------TableScan: t1 projection=[a]
diff --git a/datafusion/sqllogictest/test_files/subquery.slt b/datafusion/sqllogictest/test_files/subquery.slt
index a0ac15b740..796570633f 100644
--- a/datafusion/sqllogictest/test_files/subquery.slt
+++ b/datafusion/sqllogictest/test_files/subquery.slt
@@ -400,7 +400,7 @@ logical_plan
01)LeftSemi Join:
02)--TableScan: t1 projection=[t1_id, t1_name, t1_int]
03)--SubqueryAlias: __correlated_sq_1
-04)----Projection:
+04)----Projection:
05)------Filter: t1.t1_int < t1.t1_id
06)--------TableScan: t1 projection=[t1_id, t1_int]
@@ -1453,7 +1453,7 @@ logical_plan
01)LeftSemi Join:
02)--TableScan: t1 projection=[a]
03)--SubqueryAlias: __correlated_sq_1
-04)----Projection:
+04)----Projection:
05)------Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
06)--------TableScan: t2 projection=[]
diff --git a/datafusion/sqllogictest/test_files/union.slt b/datafusion/sqllogictest/test_files/union.slt
index 356f1598bc..fb2166150b 100644
--- a/datafusion/sqllogictest/test_files/union.slt
+++ b/datafusion/sqllogictest/test_files/union.slt
@@ -489,7 +489,7 @@ logical_plan
04)------Limit: skip=0, fetch=3
05)--------Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
06)----------SubqueryAlias: a
-07)------------Projection:
+07)------------Projection:
08)--------------Aggregate: groupBy=[[aggregate_test_100.c1]], aggr=[[]]
09)----------------Projection: aggregate_test_100.c1
10)------------------Filter: aggregate_test_100.c13 != Utf8("C2GT5KVyOPZpgKVl110TyZO0NcJ434")
diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.slt
index 52cc80eae1..c68385c49b 100644
--- a/datafusion/sqllogictest/test_files/window.slt
+++ b/datafusion/sqllogictest/test_files/window.slt
@@ -1767,7 +1767,7 @@ logical_plan
01)Projection: count(Int64(1)) AS count(*) AS global_count
02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
03)----SubqueryAlias: a
-04)------Projection:
+04)------Projection:
05)--------Aggregate: groupBy=[[aggregate_test_100.c1]], aggr=[[]]
06)----------Projection: aggregate_test_100.c1
07)------------Filter: aggregate_test_100.c13 != Utf8("C2GT5KVyOPZpgKVl110TyZO0NcJ434")
diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
index 9a85f3e6c4..352cd12c4d 100644
--- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
+++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
@@ -763,7 +763,7 @@ async fn simple_intersect() -> Result<()> {
let expected_plan_str = format!(
"Projection: count(Int64(1)) AS {syntax}\
\n Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]\
- \n Projection: \
+ \n Projection:\
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n TableScan: data projection=[a]\
@@ -780,7 +780,7 @@ async fn simple_intersect() -> Result<()> {
async fn check_constant(sql_syntax: &str, plan_expr: &str) -> Result<()> {
let expected_plan_str = format!(
"Aggregate: groupBy=[[]], aggr=[[{plan_expr}]]\
- \n Projection: \
+ \n Projection:\
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n TableScan: data projection=[a]\
@@ -942,7 +942,7 @@ async fn simple_intersect_table_reuse() -> Result<()> {
let expected_plan_str = format!(
"Projection: count(Int64(1)) AS {syntax}\
\n Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]\
- \n Projection: \
+ \n Projection:\
\n LeftSemi Join: left.a = right.a\
\n SubqueryAlias: left\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
@@ -961,7 +961,7 @@ async fn simple_intersect_table_reuse() -> Result<()> {
async fn check_constant(sql_syntax: &str, plan_expr: &str) -> Result<()> {
let expected_plan_str = format!(
"Aggregate: groupBy=[[]], aggr=[[{plan_expr}]]\
- \n Projection: \
+ \n Projection:\
\n LeftSemi Join: left.a = right.a\
\n SubqueryAlias: left\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\