Skip to content

Commit 3e89017

Browse files
tobymaoizeigerman
authored andcommitted
Reapply "fix: only limit the root node since bigquery can't handle to… (#3167)
1 parent 537cc67 commit 3e89017

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

sqlmesh/core/model/definition.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -513,26 +513,11 @@ def ctas_query(self, **render_kwarg: t.Any) -> exp.Query:
513513
Return:
514514
The mocked out ctas query.
515515
"""
516-
query = self.render_query_or_raise(**render_kwarg).copy()
516+
query = self.render_query_or_raise(**render_kwarg).limit(0)
517517

518518
for select_or_set_op in query.find_all(exp.Select, exp.SetOperation):
519-
skip_limit = False
520-
ancestor = select_or_set_op.parent
521-
while ancestor and not skip_limit:
522-
if isinstance(ancestor, exp.With) and ancestor.recursive:
523-
skip_limit = True
524-
ancestor = ancestor.parent
525-
526519
if isinstance(select_or_set_op, exp.Select) and select_or_set_op.args.get("from"):
527520
select_or_set_op.where(exp.false(), copy=False)
528-
if not skip_limit and not isinstance(select_or_set_op.parent, exp.SetOperation):
529-
select_or_set_op.limit(0, copy=False)
530-
elif (
531-
not skip_limit
532-
and isinstance(select_or_set_op, exp.SetOperation)
533-
and not isinstance(select_or_set_op.parent, exp.SetOperation)
534-
):
535-
select_or_set_op.set("limit", exp.Limit(expression=exp.Literal.number(0)))
536521

537522
if self.managed_columns:
538523
query.select(

0 commit comments

Comments
 (0)