Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Sep 3, 2022
2 parents 98045a3 + baf3016 commit ec5d32a
Show file tree
Hide file tree
Showing 10 changed files with 481 additions and 480 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 @@ -1875,11 +1875,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
20 changes: 10 additions & 10 deletions datafusion/core/tests/sql/aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ async fn csv_query_external_table_sum() {
"SELECT SUM(CAST(c7 AS BIGINT)), SUM(CAST(c8 AS BIGINT)) FROM aggregate_test_100";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+-------------------------------------------+-------------------------------------------+",
"| SUM(CAST(aggregate_test_100.c7 AS Int64)) | SUM(CAST(aggregate_test_100.c8 AS Int64)) |",
"+-------------------------------------------+-------------------------------------------+",
"| 13060 | 3017641 |",
"+-------------------------------------------+-------------------------------------------+",
"+----------------------------+----------------------------+",
"| SUM(aggregate_test_100.c7) | SUM(aggregate_test_100.c8) |",
"+----------------------------+----------------------------+",
"| 13060 | 3017641 |",
"+----------------------------+----------------------------+",
];
assert_batches_eq!(expected, &actual);
}
Expand Down Expand Up @@ -1833,11 +1833,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
410 changes: 205 additions & 205 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 CAST(test.c1 AS Int64) |",
"+---------------------------------------+",
"| 4 |",
"| 3 |",
"| |",
"| 1 |",
"+---------------------------------------+",
"+--------------------+",
"| Int64(4) - test.c1 |",
"+--------------------+",
"| 4 |",
"| 3 |",
"| |",
"| 1 |",
"+--------------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
Expand Down
72 changes: 36 additions & 36 deletions datafusion/core/tests/sql/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ async fn csv_query_cast() -> Result<()> {
let actual = execute_to_batches(&ctx, sql).await;

let expected = vec![
"+-----------------------------------------+",
"| CAST(aggregate_test_100.c12 AS Float32) |",
"+-----------------------------------------+",
"| 0.39144436 |",
"| 0.3887028 |",
"+-----------------------------------------+",
"+------------------------+",
"| aggregate_test_100.c12 |",
"+------------------------+",
"| 0.39144436 |",
"| 0.3887028 |",
"+------------------------+",
];

assert_batches_eq!(expected, &actual);
Expand All @@ -64,12 +64,12 @@ async fn csv_query_cast_literal() -> Result<()> {
let actual = execute_to_batches(&ctx, sql).await;

let expected = vec![
"+--------------------+---------------------------+",
"| c12 | CAST(Int64(1) AS Float32) |",
"+--------------------+---------------------------+",
"| 0.9294097332465232 | 1 |",
"| 0.3114712539863804 | 1 |",
"+--------------------+---------------------------+",
"+--------------------+----------+",
"| c12 | Int64(1) |",
"+--------------------+----------+",
"| 0.9294097332465232 | 1 |",
"| 0.3114712539863804 | 1 |",
"+--------------------+----------+",
];

assert_batches_eq!(expected, &actual);
Expand Down Expand Up @@ -98,14 +98,14 @@ async fn query_concat() -> Result<()> {
let sql = "SELECT concat(c1, '-hi-', cast(c2 as varchar)) FROM test";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+----------------------------------------------------+",
"| concat(test.c1,Utf8(\"-hi-\"),CAST(test.c2 AS Utf8)) |",
"+----------------------------------------------------+",
"| -hi-0 |",
"| a-hi-1 |",
"| aa-hi- |",
"| aaa-hi-3 |",
"+----------------------------------------------------+",
"+--------------------------------------+",
"| concat(test.c1,Utf8(\"-hi-\"),test.c2) |",
"+--------------------------------------+",
"| -hi-0 |",
"| a-hi-1 |",
"| aa-hi- |",
"| aaa-hi-3 |",
"+--------------------------------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
Expand Down Expand Up @@ -133,14 +133,14 @@ async fn query_array() -> Result<()> {
let sql = "SELECT make_array(c1, cast(c2 as varchar)) FROM test";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+------------------------------------------+",
"| makearray(test.c1,CAST(test.c2 AS Utf8)) |",
"+------------------------------------------+",
"| [, 0] |",
"| [a, 1] |",
"| [aa, ] |",
"| [aaa, 3] |",
"+------------------------------------------+",
"+----------------------------+",
"| makearray(test.c1,test.c2) |",
"+----------------------------+",
"| [, 0] |",
"| [a, 1] |",
"| [aa, ] |",
"| [aaa, 3] |",
"+----------------------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
Expand Down 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
24 changes: 12 additions & 12 deletions datafusion/core/tests/sql/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ async fn parquet_query() {
let sql = "SELECT id, CAST(string_col AS varchar) FROM alltypes_plain";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+----+-----------------------------------------+",
"| id | CAST(alltypes_plain.string_col AS Utf8) |",
"+----+-----------------------------------------+",
"| 4 | 0 |",
"| 5 | 1 |",
"| 6 | 0 |",
"| 7 | 1 |",
"| 2 | 0 |",
"| 3 | 1 |",
"| 0 | 0 |",
"| 1 | 1 |",
"+----+-----------------------------------------+",
"+----+---------------------------+",
"| id | alltypes_plain.string_col |",
"+----+---------------------------+",
"| 4 | 0 |",
"| 5 | 1 |",
"| 6 | 0 |",
"| 7 | 1 |",
"| 2 | 0 |",
"| 3 | 1 |",
"| 0 | 0 |",
"| 1 | 1 |",
"+----+---------------------------+",
];

assert_batches_eq!(expected, &actual);
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

0 comments on commit ec5d32a

Please sign in to comment.