Skip to content

Commit

Permalink
fix get column difference logic
Browse files Browse the repository at this point in the history
  • Loading branch information
okzapradhana committed Jun 22, 2021
1 parent ad15c63 commit e7cb8fd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions services/bigquery_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def insert(self, table, values, **schema):
''')

self.client.query(insert_query, job_config=self.job_config)
job_config = bigquery.QueryJobConfig(
dry_run=True, use_query_cache=False)

self.client.query(insert_query, job_config=job_config)

# Commit query by enqueue it if Dry Run Queue produces no error
self.commit(insert_query)
Expand Down Expand Up @@ -181,10 +184,11 @@ def delete(self, table, values, **schema):
def get_column_differences(self, table, column_names):
current_table_column = self.get_table_columns(table)

if len(column_names) > len(current_table_column):
column_differences = set(column_names).symmetric_difference(
set(current_table_column))
# Get differences column from column names in payload with column names in target table
column_differences = set(column_names).difference(
set(current_table_column))

if len(column_differences) > 0:
raise ValueError("Column {} are not exist in table {}!".format(
', '.join(column_differences), table))

Expand Down

0 comments on commit e7cb8fd

Please sign in to comment.