feat: Group By All (#964)

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
Berkay Şahin 2023-09-08 13:47:56 +03:00 committed by GitHub
parent 2593dcfb79
commit bb7b05e106
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 36 deletions

View file

@ -990,7 +990,7 @@ fn parse_copy_to() {
from: vec![],
lateral_views: vec![],
selection: None,
group_by: vec![],
group_by: GroupByExpr::Expressions(vec![]),
having: None,
named_window: vec![],
cluster_by: vec![],
@ -2019,7 +2019,7 @@ fn parse_array_subquery_expr() {
from: vec![],
lateral_views: vec![],
selection: None,
group_by: vec![],
group_by: GroupByExpr::Expressions(vec![]),
cluster_by: vec![],
distribute_by: vec![],
sort_by: vec![],
@ -2035,7 +2035,7 @@ fn parse_array_subquery_expr() {
from: vec![],
lateral_views: vec![],
selection: None,
group_by: vec![],
group_by: GroupByExpr::Expressions(vec![]),
cluster_by: vec![],
distribute_by: vec![],
sort_by: vec![],
@ -3321,14 +3321,14 @@ fn parse_select_group_by_grouping_sets() {
"SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, GROUPING SETS ((brand), (size), ())"
);
assert_eq!(
vec![
GroupByExpr::Expressions(vec![
Expr::Identifier(Ident::new("size")),
Expr::GroupingSets(vec![
vec![Expr::Identifier(Ident::new("brand"))],
vec![Expr::Identifier(Ident::new("size"))],
vec![],
]),
],
]),
select.group_by
);
}
@ -3339,13 +3339,13 @@ fn parse_select_group_by_rollup() {
"SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, ROLLUP (brand, size)",
);
assert_eq!(
vec![
GroupByExpr::Expressions(vec![
Expr::Identifier(Ident::new("size")),
Expr::Rollup(vec![
vec![Expr::Identifier(Ident::new("brand"))],
vec![Expr::Identifier(Ident::new("size"))],
]),
],
]),
select.group_by
);
}
@ -3356,13 +3356,13 @@ fn parse_select_group_by_cube() {
"SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, CUBE (brand, size)",
);
assert_eq!(
vec![
GroupByExpr::Expressions(vec![
Expr::Identifier(Ident::new("size")),
Expr::Cube(vec![
vec![Expr::Identifier(Ident::new("brand"))],
vec![Expr::Identifier(Ident::new("size"))],
]),
],
]),
select.group_by
);
}