From e84ad9c8cc39c577adce435cbac5edbe67709756 Mon Sep 17 00:00:00 2001 From: Anna Scholtz Date: Mon, 11 Dec 2023 09:24:26 -0800 Subject: [PATCH] Assume defployed materialized views are unchanged during view deploys --- bigquery_etl/view/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bigquery_etl/view/__init__.py b/bigquery_etl/view/__init__.py index 5d39ddb705e..174ff61e64a 100644 --- a/bigquery_etl/view/__init__.py +++ b/bigquery_etl/view/__init__.py @@ -254,6 +254,12 @@ def has_changes(self, target_project=None): expected_view_query = CREATE_VIEW_PATTERN.sub( "", sqlparse.format(self.content, strip_comments=True), count=1 ).strip(";" + string.whitespace) + + if table.view_query is None: + # Materialized views do not have view_query. + # Always assume they are unchanged since they can't be replaced anyway + return False + actual_view_query = sqlparse.format( table.view_query, strip_comments=True ).strip(";" + string.whitespace)