Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/unit/sqlalchemy/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ def test_ignore_nulls(dialect, function, element):
f'SELECT {function}("table".id) OVER (PARTITION BY "table".name) AS window ' \
f'\nFROM "table"'

# testing with compile kwargs
statement = select(
element(
func.round(table_without_catalog.c.id, 2),
ignore_nulls=True,
).over(partition_by=table_without_catalog.c.name).label('window')
)
query = statement.compile(dialect=dialect, compile_kwargs={"literal_binds": True})
assert str(query) == \
f'SELECT {function}(round("table".id, 2)) IGNORE NULLS OVER (PARTITION BY "table".name) AS window '\
f'\nFROM "table"'


@pytest.mark.skipif(
sqlalchemy_version() < "2.0",
Expand Down
2 changes: 1 addition & 1 deletion trino/sqlalchemy/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Lag(GenericIgnoreNulls):
@compiles(Lead)
@compiles(Lag)
def compile_ignore_nulls(element, compiler, **kwargs):
compiled = f'{element.name}({compiler.process(element.clauses)})'
compiled = f'{element.name}({compiler.process(element.clauses, **kwargs)})'
if element.ignore_nulls:
compiled += ' IGNORE NULLS'
return compiled
Expand Down