This repository was archived by the owner on Mar 6, 2026. It is now read-only.
refactor: Refactors load_table_* methods to reduce code duplication#2267
Closed
chalmerlowe wants to merge 2 commits intomainfrom
Closed
refactor: Refactors load_table_* methods to reduce code duplication#2267chalmerlowe wants to merge 2 commits intomainfrom
chalmerlowe wants to merge 2 commits intomainfrom
Conversation
This commit refactors the `load_table_from_uri`, `load_table_from_file`, `load_table_from_dataframe`, and `load_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 of `LoadJob` 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 of `LoadJobConfig` objects, merging user-provided configurations with client defaults. These changes make the loading methods more concise, easier to read, and simpler to maintain.
Collaborator
Author
|
I might come back to this, but for now, not sure the risks are worth the benefits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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_jsonmethods in the BigQuery client.A new private helper method,
_prepare_load_job, has been introduced to centralize the creation and configuration ofLoadJobobjects. 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 ofLoadJobConfigobjects, merging user-provided configurations with client defaults.These changes make the loading methods more concise, easier to read, and simpler to maintain.