Skip to content

Commit

Permalink
Make binary operator formatting consistent between logical and physic…
Browse files Browse the repository at this point in the history
…al plans (#3331)
  • Loading branch information
andygrove authored Sep 4, 2022
1 parent d7fa064 commit b175f9a
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 382 deletions.
10 changes: 5 additions & 5 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1872,11 +1872,11 @@ mod tests {
.await?;

let expected = vec![
"+----------------------+------------------------+------------------------+",
"| @@version | @name | @integer Plus Int64(1) |",
"+----------------------+------------------------+------------------------+",
"| system-var-@@version | user-defined-var-@name | 42 |",
"+----------------------+------------------------+------------------------+",
"+----------------------+------------------------+---------------------+",
"| @@version | @name | @integer + Int64(1) |",
"+----------------------+------------------------+---------------------+",
"| system-var-@@version | user-defined-var-@name | 42 |",
"+----------------------+------------------------+---------------------+",
];
assert_batches_eq!(expected, &results);

Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/physical_plan/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn create_physical_name(e: &Expr, is_first_expr: bool) -> Result<String> {
Expr::BinaryExpr { left, op, right } => {
let left = create_physical_name(left, false)?;
let right = create_physical_name(right, false)?;
Ok(format!("{} {:?} {}", left, op, right))
Ok(format!("{} {} {}", left, op, right))
}
Expr::Case {
expr,
Expand Down
10 changes: 5 additions & 5 deletions datafusion/core/tests/sql/aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,11 +1815,11 @@ async fn aggregate_avg_add() -> Result<()> {
assert_eq!(results.len(), 1);

let expected = vec![
"+--------------+----------------------------+----------------------------+----------------------------+",
"| AVG(test.c1) | AVG(test.c1) Plus Int64(1) | AVG(test.c1) Plus Int64(2) | Int64(1) Plus AVG(test.c1) |",
"+--------------+----------------------------+----------------------------+----------------------------+",
"| 1.5 | 2.5 | 3.5 | 2.5 |",
"+--------------+----------------------------+----------------------------+----------------------------+",
"+--------------+-------------------------+-------------------------+-------------------------+",
"| AVG(test.c1) | AVG(test.c1) + Int64(1) | AVG(test.c1) + Int64(2) | Int64(1) + AVG(test.c1) |",
"+--------------+-------------------------+-------------------------+-------------------------+",
"| 1.5 | 2.5 | 3.5 | 2.5 |",
"+--------------+-------------------------+-------------------------+-------------------------+",
];
assert_batches_sorted_eq!(expected, &results);

Expand Down
304 changes: 152 additions & 152 deletions datafusion/core/tests/sql/decimal.rs

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions datafusion/core/tests/sql/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,14 @@ async fn query_scalar_minus_array() -> Result<()> {
let sql = "SELECT 4 - c1 FROM test";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+------------------------+",
"| Int64(4) Minus test.c1 |",
"+------------------------+",
"| 4 |",
"| 3 |",
"| |",
"| 1 |",
"+------------------------+",
"+--------------------+",
"| Int64(4) - test.c1 |",
"+--------------------+",
"| 4 |",
"| 3 |",
"| |",
"| 1 |",
"+--------------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
Expand Down
16 changes: 8 additions & 8 deletions datafusion/core/tests/sql/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,14 @@ async fn coalesce_mul_with_default_value() -> Result<()> {
let sql = "SELECT COALESCE(c1 * c2, 0) FROM test";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------------------------------------------+",
"| coalesce(test.c1 Multiply test.c2,Int64(0)) |",
"+---------------------------------------------+",
"| 2 |",
"| 0 |",
"| 0 |",
"| 0 |",
"+---------------------------------------------+",
"+--------------------------------------+",
"| coalesce(test.c1 * test.c2,Int64(0)) |",
"+--------------------------------------+",
"| 2 |",
"| 0 |",
"| 0 |",
"| 0 |",
"+--------------------------------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
Expand Down
26 changes: 13 additions & 13 deletions datafusion/core/tests/sql/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,14 @@ async fn use_between_expression_in_select_query() -> Result<()> {
let actual = execute_to_batches(&ctx, sql).await;
// Expect field name to be correctly converted for expr, low and high.
let expected = vec![
"+--------------------------------------------------------------------+",
"| abs(test.c1) BETWEEN Int64(0) AND log(test.c1 Multiply Int64(100)) |",
"+--------------------------------------------------------------------+",
"| true |",
"| true |",
"| false |",
"| false |",
"+--------------------------------------------------------------------+",
"+-------------------------------------------------------------+",
"| abs(test.c1) BETWEEN Int64(0) AND log(test.c1 * Int64(100)) |",
"+-------------------------------------------------------------+",
"| true |",
"| true |",
"| false |",
"| false |",
"+-------------------------------------------------------------+",
];
assert_batches_eq!(expected, &actual);

Expand Down Expand Up @@ -1204,11 +1204,11 @@ async fn unprojected_filter() {
let results = df.collect().await.unwrap();

let expected = vec![
"+--------------------------+",
"| ?table?.i Plus ?table?.i |",
"+--------------------------+",
"| 6 |",
"+--------------------------+",
"+-----------------------+",
"| ?table?.i + ?table?.i |",
"+-----------------------+",
"| 6 |",
"+-----------------------+",
];
assert_batches_sorted_eq!(expected, &results);
}
Expand Down
Loading

0 comments on commit b175f9a

Please sign in to comment.