Skip to content

Commit

Permalink
Add more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Feb 2, 2023
1 parent b7bfbbf commit ba563ad
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions datafusion/sql/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,8 @@ fn select_multibyte_column() {

#[test]
fn select_groupby_orderby() {
// ensure that references are correctly resolved in the order by clause
// see https://github.com/apache/arrow-datafusion/issues/4854
let sql = r#"SELECT
avg(age) AS "value",
date_trunc('month', birth_date) AS "birth_date"
Expand All @@ -2361,6 +2363,30 @@ fn select_groupby_orderby() {
\n Aggregate: groupBy=[[person.birth_date]], aggr=[[AVG(person.age)]]\
\n TableScan: person";
quick_test(sql, expected);

// Use fully qualified `person.birth_date` as argument to date_trunc, plan should be the same
let sql = r#"SELECT
avg(age) AS "value",
date_trunc('month', person.birth_date) AS "birth_date"
FROM person GROUP BY birth_date ORDER BY birth_date;
"#;
quick_test(sql, expected);

// Use fully qualified `person.birth_date` as group by, plan should be the same
let sql = r#"SELECT
avg(age) AS "value",
date_trunc('month', birth_date) AS "birth_date"
FROM person GROUP BY person.birth_date ORDER BY birth_date;
"#;
quick_test(sql, expected);

// Use fully qualified `person.birth_date` in both group and date_trunc, plan should be the same
let sql = r#"SELECT
avg(age) AS "value",
date_trunc('month', person.birth_date) AS "birth_date"
FROM person GROUP BY person.birth_date ORDER BY birth_date;
"#;
quick_test(sql, expected);
}

fn logical_plan(sql: &str) -> Result<LogicalPlan> {
Expand Down

0 comments on commit ba563ad

Please sign in to comment.