mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Support FILTER
in over clause (#1007)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
e857a45201
commit
ce62fe6d27
15 changed files with 102 additions and 2 deletions
|
@ -290,6 +290,39 @@ fn parse_create_table_with_strict() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_window_function_with_filter() {
|
||||
for func_name in [
|
||||
"row_number",
|
||||
"rank",
|
||||
"max",
|
||||
"count",
|
||||
"user_defined_function",
|
||||
] {
|
||||
let sql = format!("SELECT {}(x) FILTER (WHERE y) OVER () FROM t", func_name);
|
||||
let select = sqlite().verified_only_select(&sql);
|
||||
assert_eq!(select.to_string(), sql);
|
||||
assert_eq!(
|
||||
select.projection,
|
||||
vec![SelectItem::UnnamedExpr(Expr::Function(Function {
|
||||
name: ObjectName(vec![Ident::new(func_name)]),
|
||||
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
|
||||
Expr::Identifier(Ident::new("x"))
|
||||
))],
|
||||
over: Some(WindowType::WindowSpec(WindowSpec {
|
||||
partition_by: vec![],
|
||||
order_by: vec![],
|
||||
window_frame: None,
|
||||
})),
|
||||
filter: Some(Box::new(Expr::Identifier(Ident::new("y")))),
|
||||
distinct: false,
|
||||
special: false,
|
||||
order_by: vec![]
|
||||
}))]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_attach_database() {
|
||||
let sql = "ATTACH DATABASE 'test.db' AS test";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue