================================================================================
SELECT statement with joins
================================================================================

SELECT a, t.a, t.b, (INTERVAL '5 minutes') as b
FROM table1 AS t
JOIN t1 ON (t.a = t1.a)
INNER JOIN t2 ON (t.a = t2.a)
FULL OUTER JOIN t2 ON t.a = t2.a
FULL JOIN t3 ON t.a = t3.a
RIGHT JOIN t4 ON t.a = t4.a
RIGHT OUTER JOIN t5 ON t.a = t5.a
LEFT JOIN t6 ON t.a = t6.a
LEFT OUTER JOIN t7 ON t.a = t7.a;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))
        (alias
          (interval_expression
            (string
              (content)))
          (identifier))))
    (from_clause
      (alias
        (identifier)
        (identifier)))
    (join_clause
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (join_clause
      (join_type)
      (identifier)
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))))

================================================================================
SELECT element from array
================================================================================

SELECT a[0];

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (array_element_access
          (identifier)
          (number))))))

================================================================================
SELECT with aliases
================================================================================

SELECT a as b, c d, e
FROM table1 AS t, table2 t2, table3

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (alias
          (identifier)
          (identifier))
        (alias
          (identifier)
          (identifier))
        (identifier)))
    (from_clause
      (alias
        (identifier)
        (identifier))
      (alias
        (identifier)
        (identifier))
      (identifier))))

================================================================================
SELECT with limit
================================================================================

SELECT * FROM foo LIMIT 10;
SELECT * FROM foo LIMIT 10, 5;
SELECT * FROM foo LIMIT 10 OFFSET 5;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (asterisk_expression)))
    (from_clause
      (identifier))
    (limit_clause
      (number)))
  (select_statement
    (select_clause
      (select_clause_body
        (asterisk_expression)))
    (from_clause
      (identifier))
    (limit_clause
      (number)
      (number)))
  (select_statement
    (select_clause
      (select_clause_body
        (asterisk_expression)))
    (from_clause
      (identifier))
    (limit_clause
      (number))
    (offset_clause
      (number))))

================================================================================
SELECT with CTE
================================================================================

WITH t AS (
    SELECT * FROM foo
)
SELECT * FROM bar;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (with_clause
      (cte
        (identifier)
        (select_statement
          (select_clause
            (select_clause_body
              (asterisk_expression)))
          (from_clause
            (identifier)))))
    (select_clause
      (select_clause_body
        (asterisk_expression)))
    (from_clause
      (identifier))))

================================================================================
SELECT with aliased join
================================================================================

SELECT foo.x, bar.y FROM foo LEFT JOIN (SELECT id, y FROM baz) baz ON baz.id = foo.id;
SELECT foo.x, bar.y FROM foo LEFT JOIN (SELECT id, y FROM baz) AS baz ON baz.id = foo.id;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (from_clause
      (identifier))
    (join_clause
      (join_type)
      (alias
        (select_subexpression
          (select_statement
            (select_clause
              (select_clause_body
                (identifier)
                (identifier)))
            (from_clause
              (identifier))))
        (identifier))
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier)))))
  (select_statement
    (select_clause
      (select_clause_body
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))
    (from_clause
      (identifier))
    (join_clause
      (join_type)
      (alias
        (select_subexpression
          (select_statement
            (select_clause
              (select_clause_body
                (identifier)
                (identifier)))
            (from_clause
              (identifier))))
        (identifier))
      (binary_expression
        (dotted_name
          (identifier)
          (identifier))
        (dotted_name
          (identifier)
          (identifier))))))

================================================================================
SELECT with LATERAL subexpression
================================================================================

SELECT * FROM LATERAL (SELECT * FROM foo) bar;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (asterisk_expression)))
    (from_clause
      (alias
        (select_subexpression
          (select_statement
            (select_clause
              (select_clause_body
                (asterisk_expression)))
            (from_clause
              (identifier))))
        (identifier)))))

================================================================================
SELECT GROUP BY
================================================================================

SELECT a, b FROM foo GROUP BY a + 1, b;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (binary_expression
          (identifier)
          (number)))
      (group_expression
        (identifier)))))

================================================================================
SELECT aggregate expressions
================================================================================

SELECT array_agg(a ORDER BY b DESC) FROM foo;
SELECT array_agg(ALL a ORDER BY b DESC) FROM foo;
SELECT array_agg(DISTINCT a ORDER BY b DESC) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier))))

================================================================================
SELECT aggregate expressions
================================================================================

SELECT array_agg(a ORDER BY b DESC) FROM foo;
SELECT array_agg(ALL a ORDER BY b DESC) FROM foo;
SELECT array_agg(DISTINCT a ORDER BY b DESC) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (order_by_clause
            (order_expression
              (identifier))))))
    (from_clause
      (identifier))))

================================================================================
SELECT GROUP BY GROUPING SETS
================================================================================

SELECT a, b FROM foo GROUP BY GROUPING SETS ((), (a), (b), (a, b), (a + 1, b + 1));

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (grouping_sets_clause
          (expression_list)
          (expression_list
            (identifier))
          (expression_list
            (identifier))
          (expression_list
            (identifier)
            (identifier))
          (expression_list
            (binary_expression
              (identifier)
              (number))
            (binary_expression
              (identifier)
              (number))))))))

================================================================================
SELECT GROUP BY ROLLUP
================================================================================

SELECT a, b FROM foo GROUP BY ROLLUP (a, (a, b), a + 1, b + 1);

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (rollup_clause
          (identifier)
          (expression_list
            (identifier)
            (identifier))
          (binary_expression
            (identifier)
            (number))
          (binary_expression
            (identifier)
            (number)))))))

================================================================================
SELECT GROUP BY CUBE
================================================================================

SELECT a, b FROM foo GROUP BY CUBE (a, (a, b), a + 1, b + 1);

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (cube_clause
          (identifier)
          (expression_list
            (identifier)
            (identifier))
          (binary_expression
            (identifier)
            (number))
          (binary_expression
            (identifier)
            (number)))))))

================================================================================
SELECT GROUP BY CUBE
================================================================================

SELECT a, b FROM foo GROUP BY CUBE (a, (a, b), a + 1, b + 1);

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (cube_clause
          (identifier)
          (expression_list
            (identifier)
            (identifier))
          (binary_expression
            (identifier)
            (number))
          (binary_expression
            (identifier)
            (number)))))))

================================================================================
SELECT GROUP BY HAVING
================================================================================

SELECT a, b FROM foo GROUP BY a, b HAVING a > b;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (identifier))
      (group_expression
        (identifier))
      (having_clause
        (binary_expression
          (identifier)
          (identifier))))))

================================================================================
SELECT GROUP BY complex
================================================================================

SELECT a, b FROM foo GROUP BY
  a + 1,
  GROUPING SETS ((), (a, b)),
  ROLLUP (a + 1, (a, b)),
  CUBE (a + 1, (a, b))
  HAVING a > b;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (identifier)
        (identifier)))
    (from_clause
      (identifier))
    (group_by_clause
      (group_expression
        (binary_expression
          (identifier)
          (number)))
      (group_expression
        (grouping_sets_clause
          (expression_list)
          (expression_list
            (identifier)
            (identifier))))
      (group_expression
        (rollup_clause
          (binary_expression
            (identifier)
            (number))
          (expression_list
            (identifier)
            (identifier))))
      (group_expression
        (cube_clause
          (binary_expression
            (identifier)
            (number))
          (expression_list
            (identifier)
            (identifier))))
      (having_clause
        (binary_expression
          (identifier)
          (identifier))))))

================================================================================
SELECT aggregate expressions within group
================================================================================

SELECT array_agg(a) WITHIN GROUP (ORDER BY b DESC) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (within_group_clause
            (order_by_clause
              (order_expression
                (identifier)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT aggregate expressions filter
================================================================================

SELECT array_agg(a) FILTER (WHERE a <> '') FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (filter_clause
            (where_clause
              (binary_expression
                (identifier)
                (string
                  (content))))))))
    (from_clause
      (identifier))))

================================================================================
SELECT aggregate expressions complex
================================================================================

SELECT
    count(*) AS unfiltered,
    count(DISTINCT *) AS distincted,
    count(DISTINCT * ORDER BY i DESC) AS ordered,
    count(*) FILTER (WHERE i < 5) AS filtered
FROM generate_series(1,10) AS s(i);

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (alias
          (function_call
            (identifier)
            (asterisk_expression))
          (identifier))
        (alias
          (function_call
            (identifier)
            (asterisk_expression))
          (identifier))
        (alias
          (function_call
            (identifier)
            (asterisk_expression)
            (order_by_clause
              (order_expression
                (identifier))))
          (identifier))
        (alias
          (function_call
            (identifier)
            (asterisk_expression)
            (filter_clause
              (where_clause
                (binary_expression
                  (identifier)
                  (number)))))
          (identifier))))
    (from_clause
      (alias
        (function_call
          (identifier)
          (number)
          (number))
        (identifier)
        (identifier)))))

================================================================================
SELECT window function call
================================================================================

SELECT avg(a) OVER () FROM foo;
SELECT avg(a) OVER win FROM foo WINDOW win AS ();

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition)))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (identifier)))))
    (from_clause
      (identifier))
    (window_clause
      (identifier)
      (window_definition))))

================================================================================
SELECT window function call with window definition
================================================================================

SELECT avg(a) OVER (PARTITION BY b, c + 1) FROM foo;
SELECT avg(a) OVER (PARTITION BY b, c + 1 ORDER BY b ASC, c DESC) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier)
                (binary_expression
                  (identifier)
                  (number))))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier)
                (binary_expression
                  (identifier)
                  (number)))
              (order_by_clause
                (order_expression
                  (identifier))
                (order_expression
                  (identifier))))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition frame_kind
================================================================================

SELECT avg(a) OVER (PARTITION BY b RANGE CURRENT ROW) FROM foo;
SELECT avg(a) OVER (PARTITION BY b ROWS CURRENT ROW) FROM foo;
SELECT avg(a) OVER (PARTITION BY b GROUPS CURRENT ROW) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition frame_start
================================================================================

SELECT avg(a) OVER (PARTITION BY b RANGE UNBOUNDED PRECEDING) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE b + 1 PRECEDING) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE b + 1 FOLLOWING) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE UNBOUNDED FOLLOWING) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition frame_end
================================================================================

SELECT avg(a) OVER (PARTITION BY b RANGE BETWEEN CURRENT ROW AND b + 1 PRECEDING) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE BETWEEN CURRENT ROW AND b + 1 PRECEDING EXCLUDE GROUP) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))
                (frame_exclusion)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition frame_exclusion
================================================================================

SELECT avg(a) OVER (PARTITION BY b RANGE CURRENT ROW EXCLUDE CURRENT ROW) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE CURRENT ROW EXCLUDE GROUP) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE CURRENT ROW EXCLUDE TIES) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE CURRENT ROW EXCLUDE NO OTHERS) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_exclusion)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_exclusion)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_exclusion)))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_exclusion)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition frame_end
================================================================================

SELECT avg(a) OVER (PARTITION BY b RANGE BETWEEN CURRENT ROW AND b + 1 PRECEDING) FROM foo;
SELECT avg(a) OVER (PARTITION BY b RANGE BETWEEN CURRENT ROW AND b + 1 PRECEDING EXCLUDE GROUP) FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))))))))
    (from_clause
      (identifier)))
  (select_statement
    (select_clause
      (select_clause_body
        (function_call
          (identifier)
          (identifier)
          (over_clause
            (window_definition
              (partition_by_clause
                (identifier))
              (frame_clause
                (frame_kind)
                (frame_bound)
                (frame_bound
                  (binary_expression
                    (identifier)
                    (number)))
                (frame_exclusion)))))))
    (from_clause
      (identifier))))

================================================================================
SELECT window function call with window definition complex
================================================================================

SELECT
  avg(a) FILTER (WHERE a > b) OVER (
    PARTITION BY b, c + 1
    ORDER BY a - 1 ASC, c + 1 DESC NULLS FIRST
    RANGE BETWEEN CURRENT ROW AND b + 1 PRECEDING
    EXCLUDE GROUP
  ) AS v1,
  max(a) FILTER (WHERE a > b) OVER (
    PARTITION BY c
    ORDER BY a DESC, b NULLS FIRST
    RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
    EXCLUDE NO OTHERS
  ) AS v2
FROM foo;

--------------------------------------------------------------------------------

(source_file
  (select_statement
    (select_clause
      (select_clause_body
        (alias
          (function_call
            (identifier)
            (identifier)
            (filter_clause
              (where_clause
                (binary_expression
                  (identifier)
                  (identifier))))
            (over_clause
              (window_definition
                (partition_by_clause
                  (identifier)
                  (binary_expression
                    (identifier)
                    (number)))
                (order_by_clause
                  (order_expression
                    (binary_expression
                      (identifier)
                      (number)))
                  (order_expression
                    (binary_expression
                      (identifier)
                      (number))))
                (frame_clause
                  (frame_kind)
                  (frame_bound)
                  (frame_bound
                    (binary_expression
                      (identifier)
                      (number)))
                  (frame_exclusion)))))
          (identifier))
        (alias
          (function_call
            (identifier)
            (identifier)
            (filter_clause
              (where_clause
                (binary_expression
                  (identifier)
                  (identifier))))
            (over_clause
              (window_definition
                (partition_by_clause
                  (identifier))
                (order_by_clause
                  (order_expression
                    (identifier))
                  (order_expression
                    (identifier)))
                (frame_clause
                  (frame_kind)
                  (frame_bound)
                  (frame_bound)
                  (frame_exclusion)))))
          (identifier))))
    (from_clause
      (identifier))))
