mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
Add support for aggregate expressions with filters (#585)
This commit is contained in:
parent
0bb49cea99
commit
303f80f168
6 changed files with 67 additions and 6 deletions
|
@ -276,6 +276,31 @@ fn parse_create_function() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filtering_during_aggregation() {
|
||||
let rename = "SELECT \
|
||||
array_agg(name) FILTER (WHERE name IS NOT NULL), \
|
||||
array_agg(name) FILTER (WHERE name LIKE 'a%') \
|
||||
FROM region";
|
||||
println!("{}", hive().verified_stmt(rename));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filtering_during_aggregation_aliased() {
|
||||
let rename = "SELECT \
|
||||
array_agg(name) FILTER (WHERE name IS NOT NULL) AS agg1, \
|
||||
array_agg(name) FILTER (WHERE name LIKE 'a%') AS agg2 \
|
||||
FROM region";
|
||||
println!("{}", hive().verified_stmt(rename));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filter_as_alias() {
|
||||
let sql = "SELECT name filter FROM region";
|
||||
let expected = "SELECT name AS filter FROM region";
|
||||
println!("{}", hive().one_statement_parses_to(sql, expected));
|
||||
}
|
||||
|
||||
fn hive() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(HiveDialect {})],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue