mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 13:40:22 +00:00
supporting snowflake extract syntax (#1374)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
ca5262c13f
commit
f5b818e74b
5 changed files with 78 additions and 3 deletions
|
@ -2019,6 +2019,35 @@ fn parse_extract_custom_part() {
|
|||
assert_eq!(
|
||||
&Expr::Extract {
|
||||
field: DateTimeField::Custom(Ident::new("eod")),
|
||||
syntax: ExtractSyntax::From,
|
||||
expr: Box::new(Expr::Identifier(Ident::new("d"))),
|
||||
},
|
||||
expr_from_projection(only(&select.projection)),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_extract_comma() {
|
||||
let sql = "SELECT EXTRACT(HOUR, d)";
|
||||
let select = snowflake_and_generic().verified_only_select(sql);
|
||||
assert_eq!(
|
||||
&Expr::Extract {
|
||||
field: DateTimeField::Hour,
|
||||
syntax: ExtractSyntax::Comma,
|
||||
expr: Box::new(Expr::Identifier(Ident::new("d"))),
|
||||
},
|
||||
expr_from_projection(only(&select.projection)),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_extract_comma_quoted() {
|
||||
let sql = "SELECT EXTRACT('hour', d)";
|
||||
let select = snowflake_and_generic().verified_only_select(sql);
|
||||
assert_eq!(
|
||||
&Expr::Extract {
|
||||
field: DateTimeField::Custom(Ident::with_quote('\'', "hour")),
|
||||
syntax: ExtractSyntax::Comma,
|
||||
expr: Box::new(Expr::Identifier(Ident::new("d"))),
|
||||
},
|
||||
expr_from_projection(only(&select.projection)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue