From 3e890172da72d98afaf41657dad03b736ef0d600 Mon Sep 17 00:00:00 2001 From: Toby Mao Date: Mon, 23 Sep 2024 16:30:13 -0700 Subject: [PATCH] =?UTF-8?q?Reapply=20"fix:=20only=20limit=20the=20root=20n?= =?UTF-8?q?ode=20since=20bigquery=20can't=20handle=20to=E2=80=A6=20(#3167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlmesh/core/model/definition.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/sqlmesh/core/model/definition.py b/sqlmesh/core/model/definition.py index 01d0c9045..88306c634 100644 --- a/sqlmesh/core/model/definition.py +++ b/sqlmesh/core/model/definition.py @@ -513,26 +513,11 @@ def ctas_query(self, **render_kwarg: t.Any) -> exp.Query: Return: The mocked out ctas query. """ - query = self.render_query_or_raise(**render_kwarg).copy() + query = self.render_query_or_raise(**render_kwarg).limit(0) for select_or_set_op in query.find_all(exp.Select, exp.SetOperation): - skip_limit = False - ancestor = select_or_set_op.parent - while ancestor and not skip_limit: - if isinstance(ancestor, exp.With) and ancestor.recursive: - skip_limit = True - ancestor = ancestor.parent - if isinstance(select_or_set_op, exp.Select) and select_or_set_op.args.get("from"): select_or_set_op.where(exp.false(), copy=False) - if not skip_limit and not isinstance(select_or_set_op.parent, exp.SetOperation): - select_or_set_op.limit(0, copy=False) - elif ( - not skip_limit - and isinstance(select_or_set_op, exp.SetOperation) - and not isinstance(select_or_set_op.parent, exp.SetOperation) - ): - select_or_set_op.set("limit", exp.Limit(expression=exp.Literal.number(0))) if self.managed_columns: query.select(