From a0b43616ff863e744dfd7f172c05d916be92e395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Far=C3=ADas=20Santana?= Date: Wed, 11 Dec 2024 17:11:35 +0100 Subject: [PATCH] fix: Include partition column if present (#26838) --- .../temporal/batch_exports/bigquery_batch_export.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/posthog/temporal/batch_exports/bigquery_batch_export.py b/posthog/temporal/batch_exports/bigquery_batch_export.py index b1eee8b98d0b7..edaf13d1888af 100644 --- a/posthog/temporal/batch_exports/bigquery_batch_export.py +++ b/posthog/temporal/batch_exports/bigquery_batch_export.py @@ -295,9 +295,14 @@ async def acheck_for_query_permissions_on_table( ): """Attempt to SELECT from table to check for query permissions.""" job_config = bigquery.QueryJobConfig() - query = f""" - SELECT 1 FROM `{table.full_table_id.replace(":", ".", 1)}` - """ + if "timestamp" in [field.name for field in table.schema]: + query = f""" + SELECT 1 FROM `{table.full_table_id.replace(":", ".", 1)}` WHERE timestamp IS NOT NULL + """ + else: + query = f""" + SELECT 1 FROM `{table.full_table_id.replace(":", ".", 1)}` + """ try: query_job = self.query(query, job_config=job_config)