mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
Snowflake: Add support for CONNECT_BY_ROOT
(#1780)
This commit is contained in:
parent
4e392f5c07
commit
2b5bdcef0b
8 changed files with 107 additions and 20 deletions
|
@ -3983,3 +3983,45 @@ fn test_nested_join_without_parentheses() {
|
|||
}],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_connect_by_root_operator() {
|
||||
let sql = "SELECT CONNECT_BY_ROOT name AS root_name FROM Tbl1";
|
||||
|
||||
match snowflake().verified_stmt(sql) {
|
||||
Statement::Query(query) => {
|
||||
assert_eq!(
|
||||
query.body.as_select().unwrap().projection[0],
|
||||
SelectItem::ExprWithAlias {
|
||||
expr: Expr::Prefixed {
|
||||
prefix: Ident::new("CONNECT_BY_ROOT"),
|
||||
value: Box::new(Expr::Identifier(Ident::new("name")))
|
||||
},
|
||||
alias: Ident::new("root_name"),
|
||||
}
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let sql = "SELECT CONNECT_BY_ROOT name FROM Tbl2";
|
||||
match snowflake().verified_stmt(sql) {
|
||||
Statement::Query(query) => {
|
||||
assert_eq!(
|
||||
query.body.as_select().unwrap().projection[0],
|
||||
SelectItem::UnnamedExpr(Expr::Prefixed {
|
||||
prefix: Ident::new("CONNECT_BY_ROOT"),
|
||||
value: Box::new(Expr::Identifier(Ident::new("name")))
|
||||
})
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let sql = "SELECT CONNECT_BY_ROOT FROM Tbl2";
|
||||
let res = snowflake().parse_sql_statements(sql);
|
||||
assert_eq!(
|
||||
res.unwrap_err().to_string(),
|
||||
"sql parser error: Expected an expression, found: FROM"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue