DerekStride / tree-sitter-sql

SQL grammar for tree-sitter
http://derek.stride.host/tree-sitter-sql/
MIT License
147 stars 47 forks source link

IGNORE NULLS breaks window function parsing #245

Closed yusufshalaby closed 5 months ago

yusufshalaby commented 5 months ago

Minimal example with "IGNORE NULLS" included in the window function.

Screenshot 2024-03-22 at 11 35 28 AM

And here it is working without: Screenshot 2024-03-22 at 11 33 41 AM

select
    last_value(a) ignore nulls over (
        partition by c
        order by d
        rows between unbounded preceding and unbounded following
    ) as a,
    last_value(b) ignore nulls over (
        partition by c
        order by d
        rows between unbounded preceding and unbounded following
    ) as b
from some_table
where a = 1
yusufshalaby commented 5 months ago

Modifying the sql to the following fixes the issue:

select
    last_value(a ignore nulls) over (
        partition by c
        order by d
        rows between unbounded preceding and unbounded following
    ) as a,
    last_value(b ignore nulls) over (
        partition by c
        order by d
        rows between unbounded preceding and unbounded following
    ) as b
from some_table
where a = 1