@@ -875,6 +875,7 @@ fn parse_select_count_wildcard() {
875
875
& Expr :: Function ( Function {
876
876
name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
877
877
args: vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Wildcard ) ] ,
878
+ null_treatment: None ,
878
879
filter: None ,
879
880
over: None ,
880
881
distinct: false ,
@@ -896,6 +897,7 @@ fn parse_select_count_distinct() {
896
897
op: UnaryOperator :: Plus ,
897
898
expr: Box :: new( Expr :: Identifier ( Ident :: new( "x" ) ) ) ,
898
899
} ) ) ] ,
900
+ null_treatment: None ,
899
901
filter: None ,
900
902
over: None ,
901
903
distinct: true ,
@@ -1864,6 +1866,7 @@ fn parse_select_having() {
1864
1866
left: Box :: new( Expr :: Function ( Function {
1865
1867
name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
1866
1868
args: vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Wildcard ) ] ,
1869
+ null_treatment: None ,
1867
1870
filter: None ,
1868
1871
over: None ,
1869
1872
distinct: false ,
@@ -1890,6 +1893,7 @@ fn parse_select_qualify() {
1890
1893
left: Box :: new( Expr :: Function ( Function {
1891
1894
name: ObjectName ( vec![ Ident :: new( "ROW_NUMBER" ) ] ) ,
1892
1895
args: vec![ ] ,
1896
+ null_treatment: None ,
1893
1897
filter: None ,
1894
1898
over: Some ( WindowType :: WindowSpec ( WindowSpec {
1895
1899
partition_by: vec![ Expr :: Identifier ( Ident :: new( "p" ) ) ] ,
@@ -2287,6 +2291,45 @@ fn parse_agg_with_order_by() {
2287
2291
}
2288
2292
}
2289
2293
2294
+ #[ test]
2295
+ fn parse_window_rank_function ( ) {
2296
+ let supported_dialects = TestedDialects {
2297
+ dialects : vec ! [
2298
+ Box :: new( GenericDialect { } ) ,
2299
+ Box :: new( PostgreSqlDialect { } ) ,
2300
+ Box :: new( MsSqlDialect { } ) ,
2301
+ Box :: new( AnsiDialect { } ) ,
2302
+ Box :: new( HiveDialect { } ) ,
2303
+ Box :: new( SnowflakeDialect { } ) ,
2304
+ ] ,
2305
+ options : None ,
2306
+ } ;
2307
+
2308
+ for sql in [
2309
+ "SELECT column1, column2, FIRST_VALUE(column2) OVER (PARTITION BY column1 ORDER BY column2 NULLS LAST) AS column2_first FROM t1" ,
2310
+ "SELECT column1, column2, FIRST_VALUE(column2) OVER (ORDER BY column2 NULLS LAST) AS column2_first FROM t1" ,
2311
+ "SELECT col_1, col_2, LAG(col_2) OVER (ORDER BY col_1) FROM t1" ,
2312
+ "SELECT LAG(col_2, 1, 0) OVER (ORDER BY col_1) FROM t1" ,
2313
+ "SELECT LAG(col_2, 1, 0) OVER (PARTITION BY col_3 ORDER BY col_1)" ,
2314
+ ] {
2315
+ supported_dialects. verified_stmt ( sql) ;
2316
+ }
2317
+
2318
+ let supported_dialects_nulls = TestedDialects {
2319
+ dialects : vec ! [ Box :: new( MsSqlDialect { } ) , Box :: new( SnowflakeDialect { } ) ] ,
2320
+ options : None ,
2321
+ } ;
2322
+
2323
+ for sql in [
2324
+ "SELECT column1, column2, FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1 ORDER BY column2 NULLS LAST) AS column2_first FROM t1" ,
2325
+ "SELECT column1, column2, FIRST_VALUE(column2) RESPECT NULLS OVER (PARTITION BY column1 ORDER BY column2 NULLS LAST) AS column2_first FROM t1" ,
2326
+ "SELECT LAG(col_2, 1, 0) IGNORE NULLS OVER (ORDER BY col_1) FROM t1" ,
2327
+ "SELECT LAG(col_2, 1, 0) RESPECT NULLS OVER (ORDER BY col_1) FROM t1" ,
2328
+ ] {
2329
+ supported_dialects_nulls. verified_stmt ( sql) ;
2330
+ }
2331
+ }
2332
+
2290
2333
#[ test]
2291
2334
fn parse_create_table ( ) {
2292
2335
let sql = "CREATE TABLE uk_cities (\
@@ -3346,6 +3389,7 @@ fn parse_scalar_function_in_projection() {
3346
3389
args: vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr (
3347
3390
Expr :: Identifier ( Ident :: new( "id" ) )
3348
3391
) ) ] ,
3392
+ null_treatment: None ,
3349
3393
filter: None ,
3350
3394
over: None ,
3351
3395
distinct: false ,
@@ -3466,6 +3510,7 @@ fn parse_named_argument_function() {
3466
3510
) ) ) ,
3467
3511
} ,
3468
3512
] ,
3513
+ null_treatment: None ,
3469
3514
filter: None ,
3470
3515
over: None ,
3471
3516
distinct: false ,
@@ -3498,6 +3543,7 @@ fn parse_window_functions() {
3498
3543
& Expr :: Function ( Function {
3499
3544
name: ObjectName ( vec![ Ident :: new( "row_number" ) ] ) ,
3500
3545
args: vec![ ] ,
3546
+ null_treatment: None ,
3501
3547
filter: None ,
3502
3548
over: Some ( WindowType :: WindowSpec ( WindowSpec {
3503
3549
partition_by: vec![ ] ,
@@ -3542,6 +3588,7 @@ fn test_parse_named_window() {
3542
3588
quote_style: None ,
3543
3589
} ) ,
3544
3590
) ) ] ,
3591
+ null_treatment: None ,
3545
3592
filter: None ,
3546
3593
over: Some ( WindowType :: NamedWindow ( Ident {
3547
3594
value: "window1" . to_string( ) ,
@@ -3568,6 +3615,7 @@ fn test_parse_named_window() {
3568
3615
quote_style: None ,
3569
3616
} ) ,
3570
3617
) ) ] ,
3618
+ null_treatment: None ,
3571
3619
filter: None ,
3572
3620
over: Some ( WindowType :: NamedWindow ( Ident {
3573
3621
value: "window2" . to_string( ) ,
@@ -4038,6 +4086,7 @@ fn parse_at_timezone() {
4038
4086
quote_style: None ,
4039
4087
} ] ) ,
4040
4088
args: vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( zero. clone( ) ) ) ] ,
4089
+ null_treatment: None ,
4041
4090
filter: None ,
4042
4091
over: None ,
4043
4092
distinct: false ,
@@ -4066,6 +4115,7 @@ fn parse_at_timezone() {
4066
4115
quote_style: None ,
4067
4116
} , ] , ) ,
4068
4117
args: vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( zero) ) ] ,
4118
+ null_treatment: None ,
4069
4119
filter: None ,
4070
4120
over: None ,
4071
4121
distinct: false ,
@@ -4078,6 +4128,7 @@ fn parse_at_timezone() {
4078
4128
Value :: SingleQuotedString ( "%Y-%m-%dT%H" . to_string( ) ) ,
4079
4129
) , ) , ) ,
4080
4130
] ,
4131
+ null_treatment: None ,
4081
4132
filter: None ,
4082
4133
over: None ,
4083
4134
distinct: false ,
@@ -4237,6 +4288,7 @@ fn parse_table_function() {
4237
4288
args : vec ! [ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value (
4238
4289
Value :: SingleQuotedString ( "1" . to_owned( ) ) ,
4239
4290
) ) ) ] ,
4291
+ null_treatment : None ,
4240
4292
filter : None ,
4241
4293
over : None ,
4242
4294
distinct : false ,
@@ -4389,6 +4441,7 @@ fn parse_unnest_in_from_clause() {
4389
4441
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "2" ) ) ) ) ,
4390
4442
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "3" ) ) ) ) ,
4391
4443
] ,
4444
+ null_treatment: None ,
4392
4445
filter: None ,
4393
4446
over: None ,
4394
4447
distinct: false ,
@@ -4419,6 +4472,7 @@ fn parse_unnest_in_from_clause() {
4419
4472
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "2" ) ) ) ) ,
4420
4473
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "3" ) ) ) ) ,
4421
4474
] ,
4475
+ null_treatment: None ,
4422
4476
filter: None ,
4423
4477
over: None ,
4424
4478
distinct: false ,
@@ -4431,6 +4485,7 @@ fn parse_unnest_in_from_clause() {
4431
4485
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "5" ) ) ) ) ,
4432
4486
FunctionArg :: Unnamed ( FunctionArgExpr :: Expr ( Expr :: Value ( number( "6" ) ) ) ) ,
4433
4487
] ,
4488
+ null_treatment: None ,
4434
4489
filter: None ,
4435
4490
over: None ,
4436
4491
distinct: false ,
@@ -6904,6 +6959,7 @@ fn parse_time_functions() {
6904
6959
let select_localtime_func_call_ast = Function {
6905
6960
name : ObjectName ( vec ! [ Ident :: new( func_name) ] ) ,
6906
6961
args : vec ! [ ] ,
6962
+ null_treatment : None ,
6907
6963
filter : None ,
6908
6964
over : None ,
6909
6965
distinct : false ,
@@ -7391,6 +7447,7 @@ fn parse_pivot_table() {
7391
7447
args: ( vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr (
7392
7448
Expr :: CompoundIdentifier ( vec![ Ident :: new( "a" ) , Ident :: new( "amount" ) , ] )
7393
7449
) ) ] ) ,
7450
+ null_treatment: None ,
7394
7451
filter: None ,
7395
7452
over: None ,
7396
7453
distinct: false ,
@@ -7541,6 +7598,7 @@ fn parse_pivot_unpivot_table() {
7541
7598
args: ( vec![ FunctionArg :: Unnamed ( FunctionArgExpr :: Expr (
7542
7599
Expr :: Identifier ( Ident :: new( "population" ) )
7543
7600
) ) ] ) ,
7601
+ null_treatment: None ,
7544
7602
filter: None ,
7545
7603
over: None ,
7546
7604
distinct: false ,
0 commit comments