mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
feat: Group By All (#964)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
2593dcfb79
commit
bb7b05e106
9 changed files with 85 additions and 36 deletions
|
@ -247,7 +247,9 @@ fn parse_update_set_from() {
|
|||
}],
|
||||
lateral_views: vec![],
|
||||
selection: None,
|
||||
group_by: vec![Expr::Identifier(Ident::new("id"))],
|
||||
group_by: GroupByExpr::Expressions(vec![Expr::Identifier(Ident::new(
|
||||
"id"
|
||||
))]),
|
||||
cluster_by: vec![],
|
||||
distribute_by: vec![],
|
||||
sort_by: vec![],
|
||||
|
@ -1808,10 +1810,10 @@ fn parse_select_group_by() {
|
|||
let sql = "SELECT id, fname, lname FROM customer GROUP BY lname, fname";
|
||||
let select = verified_only_select(sql);
|
||||
assert_eq!(
|
||||
vec![
|
||||
GroupByExpr::Expressions(vec![
|
||||
Expr::Identifier(Ident::new("lname")),
|
||||
Expr::Identifier(Ident::new("fname")),
|
||||
],
|
||||
]),
|
||||
select.group_by
|
||||
);
|
||||
|
||||
|
@ -1822,6 +1824,18 @@ fn parse_select_group_by() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_group_by_all() {
|
||||
let sql = "SELECT id, fname, lname, SUM(order) FROM customer GROUP BY ALL";
|
||||
let select = verified_only_select(sql);
|
||||
assert_eq!(GroupByExpr::All, select.group_by);
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT id, fname, lname, SUM(order) FROM customer GROUP BY ALL",
|
||||
"SELECT id, fname, lname, SUM(order) FROM customer GROUP BY ALL",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_having() {
|
||||
let sql = "SELECT foo FROM bar GROUP BY foo HAVING COUNT(*) > 1";
|
||||
|
@ -3543,7 +3557,7 @@ fn test_parse_named_window() {
|
|||
}],
|
||||
lateral_views: vec![],
|
||||
selection: None,
|
||||
group_by: vec![],
|
||||
group_by: GroupByExpr::Expressions(vec![]),
|
||||
cluster_by: vec![],
|
||||
distribute_by: vec![],
|
||||
sort_by: vec![],
|
||||
|
@ -3930,7 +3944,7 @@ fn parse_interval_and_or_xor() {
|
|||
}),
|
||||
}),
|
||||
}),
|
||||
group_by: vec![],
|
||||
group_by: GroupByExpr::Expressions(vec![]),
|
||||
cluster_by: vec![],
|
||||
distribute_by: vec![],
|
||||
sort_by: vec![],
|
||||
|
@ -6333,7 +6347,7 @@ fn parse_merge() {
|
|||
}],
|
||||
lateral_views: vec![],
|
||||
selection: None,
|
||||
group_by: vec![],
|
||||
group_by: GroupByExpr::Expressions(vec![]),
|
||||
cluster_by: vec![],
|
||||
distribute_by: vec![],
|
||||
sort_by: vec![],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue