Skip to content

Commit

Permalink
add more UT and delete redundant test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Dec 11, 2022
1 parent 74cea47 commit f3a2890
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
21 changes: 0 additions & 21 deletions datafusion/core/tests/sql/group_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f3a2890

Please sign in to comment.