mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
Move tests from parser.rs to appropriate parse_XX tests (#845)
* Move tests from parser.rs to appropriate parse_XX tests * move to postgres tests * move more tests
This commit is contained in:
parent
784a19138f
commit
00d071286b
4 changed files with 79 additions and 119 deletions
|
@ -513,6 +513,11 @@ fn parse_simple_select() {
|
|||
assert_eq!(Some(Expr::Value(number("5"))), select.limit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_limit() {
|
||||
verified_stmt("SELECT * FROM user LIMIT 1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_limit_is_not_an_alias() {
|
||||
// In dialects supporting LIMIT it shouldn't be parsed as a table alias
|
||||
|
@ -1559,65 +1564,6 @@ fn parse_select_group_by() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_group_by_grouping_sets() {
|
||||
let dialects = TestedDialects {
|
||||
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
|
||||
};
|
||||
let sql =
|
||||
"SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, GROUPING SETS ((brand), (size), ())";
|
||||
let select = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_group_by_rollup() {
|
||||
let dialects = TestedDialects {
|
||||
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
|
||||
};
|
||||
let sql = "SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, ROLLUP (brand, size)";
|
||||
let select = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
vec![
|
||||
Expr::Identifier(Ident::new("size")),
|
||||
Expr::Rollup(vec![
|
||||
vec![Expr::Identifier(Ident::new("brand"))],
|
||||
vec![Expr::Identifier(Ident::new("size"))],
|
||||
]),
|
||||
],
|
||||
select.group_by
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_group_by_cube() {
|
||||
let dialects = TestedDialects {
|
||||
dialects: vec![Box::new(GenericDialect {}), Box::new(PostgreSqlDialect {})],
|
||||
};
|
||||
let sql = "SELECT brand, size, sum(sales) FROM items_sold GROUP BY size, CUBE (brand, size)";
|
||||
let select = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
vec![
|
||||
Expr::Identifier(Ident::new("size")),
|
||||
Expr::Cube(vec![
|
||||
vec![Expr::Identifier(Ident::new("brand"))],
|
||||
vec![Expr::Identifier(Ident::new("size"))],
|
||||
]),
|
||||
],
|
||||
select.group_by
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_having() {
|
||||
let sql = "SELECT foo FROM bar GROUP BY foo HAVING COUNT(*) > 1";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue