refactor: Refactors load_table_* methods to reduce code duplication #2267
+73
−68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit refactors the
load_table_from_uri
,load_table_from_file
,load_table_from_dataframe
, andload_table_from_json
methods in the BigQuery client.A new private helper method,
_prepare_load_job
, has been introduced to centralize the creation and configuration ofLoadJob
objects. This eliminates redundant code for setting up job IDs, projects, and locations.A second helper,
_prepare_load_config
, was also added to standardize the handling ofLoadJobConfig
objects, merging user-provided configurations with client defaults.These changes make the loading methods more concise, easier to read, and simpler to maintain.