Skip to content

Commit 178a83a

Browse files
committed
fix: add lost compile kwargs
1 parent 2108c38 commit 178a83a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

tests/unit/sqlalchemy/test_compiler.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ def test_ignore_nulls(dialect, function, element):
182182
f'SELECT {function}("table".id) OVER (PARTITION BY "table".name) AS window ' \
183183
f'\nFROM "table"'
184184

185+
# testing with compile kwargs
186+
statement = select(
187+
element(
188+
func.round(table_without_catalog.c.id, 2),
189+
ignore_nulls=True,
190+
).over(partition_by=table_without_catalog.c.name).label('window')
191+
)
192+
query = statement.compile(dialect=dialect, compile_kwargs={"literal_binds": True})
193+
assert str(query) == \
194+
f'SELECT {function}(round("table".id, 2)) IGNORE NULLS OVER (PARTITION BY "table".name) AS window '\
195+
f'\nFROM "table"'
196+
185197

186198
@pytest.mark.skipif(
187199
sqlalchemy_version() < "2.0",

trino/sqlalchemy/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Lag(GenericIgnoreNulls):
172172
@compiles(Lead)
173173
@compiles(Lag)
174174
def compile_ignore_nulls(element, compiler, **kwargs):
175-
compiled = f'{element.name}({compiler.process(element.clauses)})'
175+
compiled = f'{element.name}({compiler.process(element.clauses, **kwargs)})'
176176
if element.ignore_nulls:
177177
compiled += ' IGNORE NULLS'
178178
return compiled

0 commit comments

Comments
 (0)