Skip to content

Commit 9dbce81

Browse files
authored
Fix: port sqlglot pipe syntax fix in _parse_select (#5373)
1 parent 9d7f3a0 commit 9dbce81

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

sqlmesh/core/dialect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,15 @@ def _parse_select(
350350
parse_subquery_alias: bool = True,
351351
parse_set_operation: bool = True,
352352
consume_pipe: bool = True,
353+
from_: t.Optional[exp.From] = None,
353354
) -> t.Optional[exp.Expression]:
354355
select = self.__parse_select( # type: ignore
355356
nested=nested,
356357
table=table,
357358
parse_subquery_alias=parse_subquery_alias,
358359
parse_set_operation=parse_set_operation,
359360
consume_pipe=consume_pipe,
361+
from_=from_,
360362
)
361363

362364
if (

tests/core/test_dialect.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,11 @@ def test_sqlglot_extended_correctly(dialect: str) -> None:
722722
def test_connected_identifier():
723723
ast = d.parse_one("""SELECT ("x"at time zone 'utc')::timestamp as x""", "redshift")
724724
assert ast.sql("redshift") == """SELECT CAST(("x" AT TIME ZONE 'utc') AS TIMESTAMP) AS x"""
725+
726+
727+
def test_pipe_syntax():
728+
ast = d.parse_one("SELECT * FROM (FROM t2 |> SELECT id)", "bigquery")
729+
assert (
730+
ast.sql("bigquery")
731+
== "SELECT * FROM (WITH __tmp1 AS (SELECT id FROM t2) SELECT * FROM __tmp1)"
732+
)

0 commit comments

Comments
 (0)