From 3ddab724d8a1724f254117df84405458f8181ba0 Mon Sep 17 00:00:00 2001 From: Chamikara Jayalath Date: Thu, 25 Feb 2021 13:19:14 -0800 Subject: [PATCH] Puts more expensive BQ empty table check to the right of the 'and' condition --- sdks/python/apache_beam/io/gcp/bigquery_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/io/gcp/bigquery_tools.py b/sdks/python/apache_beam/io/gcp/bigquery_tools.py index 056182992329..d61e01ab0a69 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery_tools.py +++ b/sdks/python/apache_beam/io/gcp/bigquery_tools.py @@ -930,8 +930,8 @@ def get_or_create_table( # specified. if write_disposition == BigQueryDisposition.WRITE_TRUNCATE: self._delete_table(project_id, dataset_id, table_id) - elif (not self._is_table_empty(project_id, dataset_id, table_id) and - write_disposition == BigQueryDisposition.WRITE_EMPTY): + elif (write_disposition == BigQueryDisposition.WRITE_EMPTY and + not self._is_table_empty(project_id, dataset_id, table_id)): raise RuntimeError( 'Table %s:%s.%s is not empty but write disposition is WRITE_EMPTY.' % (project_id, dataset_id, table_id))