Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make binary operator formatting consistent between logical and physical plans #3331

Merged
merged 5 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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