Skip to content

Commit

Permalink
window function test
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-rus committed Nov 11, 2024
1 parent ad6ee9d commit 2fb6ce4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_parser/test_base_sql/test_select_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,3 +1186,23 @@ def test_table_double_quote(self):

ast = parse_sql(sql)
assert str(ast) == str(expected_ast)

def test_window_function_mindsdb(self):

# modifier
query = "select SUM(col0) OVER (partition by col1 order by col2 rows between unbounded preceding and current row) from table1 "
expected_ast = Select(
targets=[
WindowFunction(
function=Function(op='sum', args=[Identifier('col0')]),
partition=[Identifier('col1')],
order_by=[OrderBy(field=Identifier('col2'))],
modifier='rows BETWEEN unbounded preceding AND current row'
)
],
from_table=Identifier('table1')
)
ast = parse_sql(query)
assert str(ast) == str(expected_ast)
assert ast.to_tree() == expected_ast.to_tree()

0 comments on commit 2fb6ce4

Please sign in to comment.