From f3a28902b137259b2bb855d7eb9829aad0608f7b Mon Sep 17 00:00:00 2001 From: jackwener Date: Sun, 11 Dec 2022 21:38:51 +0800 Subject: [PATCH] add more UT and delete redundant test. --- datafusion/core/tests/sql/group_by.rs | 21 --------------------- datafusion/sql/src/planner.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/datafusion/core/tests/sql/group_by.rs b/datafusion/core/tests/sql/group_by.rs index 6df11a8ceae42..5fb106d440e86 100644 --- a/datafusion/core/tests/sql/group_by.rs +++ b/datafusion/core/tests/sql/group_by.rs @@ -190,27 +190,6 @@ async fn csv_query_group_by_and_having_and_where() -> Result<()> { Ok(()) } -#[tokio::test] -async fn csv_query_having_without_group_by() -> Result<()> { - let ctx = SessionContext::new(); - register_aggregate_csv(&ctx).await?; - let sql = "SELECT c1, c2, c3 FROM aggregate_test_100 where c2 >= 4 AND c3 > 90"; - let actual = execute_to_batches(&ctx, sql).await; - let expected = vec![ - "+----+----+-----+", - "| c1 | c2 | c3 |", - "+----+----+-----+", - "| c | 4 | 123 |", - "| c | 5 | 118 |", - "| d | 4 | 102 |", - "| e | 4 | 96 |", - "| e | 4 | 97 |", - "+----+----+-----+", - ]; - assert_batches_sorted_eq!(expected, &actual); - Ok(()) -} - #[tokio::test] async fn csv_query_group_by_substr() -> Result<()> { let ctx = SessionContext::new(); diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index e8fb5cabd2bc1..035f122385942 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -3651,6 +3651,19 @@ mod tests { ); } + #[test] + fn select_with_having_refers_to_invalid_column() { + let sql = "SELECT id, MAX(age) + FROM person + GROUP BY id + HAVING first_name = 'M'"; + let err = logical_plan(sql).expect_err("query should have failed"); + assert_eq!( + "Plan(\"HAVING clause references non-aggregate values: Expression person.first_name could not be resolved from available columns: person.id, MAX(person.age)\")", + format!("{:?}", err) + ); + } + #[test] fn select_with_having_referencing_column_nested_in_select_expression() { let sql = "SELECT id, age + 1