Skip to content

Commit

Permalink
Fix: unnest subqueries in executor closes #1835
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Jun 27, 2023
1 parent 9de9667 commit cb0ac10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def from_expression(
A Step DAG corresponding to `expression`.
"""
ctes = ctes or {}
expression = expression.unnest()
with_ = expression.args.get("with")

# CTEs break the mold of scope and introduce themselves to all in the context.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ def test_set_operations(self):
["a"],
[("a",)],
),
(
"(SELECT a FROM x) EXCEPT (SELECT a FROM y)",
["a"],
[("a",)],
),
(
"SELECT a FROM x INTERSECT SELECT a FROM y",
["a"],
Expand Down

0 comments on commit cb0ac10

Please sign in to comment.