@@ -235,6 +235,16 @@ def group_identifier(tlist):
235
235
tidx , token = tlist .token_next_by (t = ttypes , idx = tidx )
236
236
237
237
238
+ @recurse (sql .Over )
239
+ def group_over (tlist ):
240
+ tidx , token = tlist .token_next_by (m = sql .Over .M_OPEN )
241
+ while token :
242
+ nidx , next_ = tlist .token_next (tidx )
243
+ if imt (next_ , i = sql .Parenthesis , t = T .Name ):
244
+ tlist .group_tokens (sql .Over , tidx , nidx )
245
+ tidx , token = tlist .token_next_by (m = sql .Over .M_OPEN , idx = tidx )
246
+
247
+
238
248
def group_arrays (tlist ):
239
249
sqlcls = sql .SquareBrackets , sql .Identifier , sql .Function
240
250
ttypes = T .Name , T .String .Symbol
@@ -361,7 +371,12 @@ def group_functions(tlist):
361
371
while token :
362
372
nidx , next_ = tlist .token_next (tidx )
363
373
if isinstance (next_ , sql .Parenthesis ):
364
- tlist .group_tokens (sql .Function , tidx , nidx )
374
+ over_idx , over = tlist .token_next (nidx )
375
+ if over and isinstance (over , sql .Over ):
376
+ eidx = over_idx
377
+ else :
378
+ eidx = nidx
379
+ tlist .group_tokens (sql .Function , tidx , eidx )
365
380
tidx , token = tlist .token_next_by (t = T .Name , idx = tidx )
366
381
367
382
@@ -412,6 +427,7 @@ def group(stmt):
412
427
group_for ,
413
428
group_begin ,
414
429
430
+ group_over ,
415
431
group_functions ,
416
432
group_where ,
417
433
group_period ,
0 commit comments