Skip to content

Commit

Permalink
Move variable definition outside try/except block (#1030)
Browse files Browse the repository at this point in the history
the variable definition is used in the except block, so if the
variable definition fails, the except block will raise another
variable not defined exception

Co-authored-by: Shauna <[email protected]>
  • Loading branch information
austinweisgrau and shaunagm authored May 23, 2024
1 parent ec55b51 commit fb05867
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions parsons/google/google_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,13 +1328,14 @@ def _validate_copy_inputs(self, if_exists: str, data_type: str):
raise ValueError(f"Only supports csv or json files [data_type = {data_type}]")

def _load_table_from_uri(self, source_uris, destination, job_config, **load_kwargs):
load_job = self.client.load_table_from_uri(
source_uris=source_uris,
destination=destination,
job_config=job_config,
**load_kwargs,
)

try:
load_job = self.client.load_table_from_uri(
source_uris=source_uris,
destination=destination,
job_config=job_config,
**load_kwargs,
)
load_job.result()
return load_job
except exceptions.BadRequest as e:
Expand Down

0 comments on commit fb05867

Please sign in to comment.