From dd51436086f0123abe7a31bb24d5515b936a091d Mon Sep 17 00:00:00 2001 From: lovasoa Date: Fri, 20 Oct 2023 22:30:12 +0200 Subject: [PATCH] test with a non-aggregate window function name addresses https://github.com/sqlparser-rs/sqlparser-rs/pull/1007/files#r1367383050 --- tests/sqlparser_sqlite.rs | 50 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tests/sqlparser_sqlite.rs b/tests/sqlparser_sqlite.rs index 1b86fd701..8d7ccf315 100644 --- a/tests/sqlparser_sqlite.rs +++ b/tests/sqlparser_sqlite.rs @@ -292,27 +292,35 @@ fn parse_create_table_with_strict() { #[test] fn parse_window_function_with_filter() { - let sql = "SELECT max(x) FILTER (WHERE y) OVER () FROM t"; - 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("max")]), - 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![] - }))] - ); + 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]