TobikoData / sqlmesh

Efficient data transformation and modeling framework that is backwards compatible with dbt.

Home Page:https://sqlmesh.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move window function comments at the end of the whole expression

georgesittas opened this issue · comments

commented

This is a SQLGlot issue, context can be found at: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1710771103241089.

Example:

>>> import sqlglot
>>>
>>> sqlglot.transpile("""
... SELECT
...   -- comment
...   SOME_FUNC(arg IGNORE NULLS)
...     OVER (PARTITION BY foo ORDER BY bla) AS col
... """)
['SELECT SOME_FUNC(arg IGNORE NULLS) /* comment */ OVER (PARTITION BY foo ORDER BY bla) AS col']

Notice how we've moved the comment in the middle of the expression. This is because it's stored in a nested AST node and not in the Window itself.