-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: disambiguate google-cloud-bigquery to_dataframe usage from pandas-gbq in ua.
#18369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tswast
wants to merge
1
commit into
main
Choose a base branch
from
b540939659-user-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+295
−40
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,7 @@ | |
| _versions_helpers, | ||
| enums, | ||
| job, | ||
| version, | ||
| ) | ||
| from google.cloud.bigquery import exceptions as bq_exceptions | ||
| from google.cloud.bigquery._helpers import ( | ||
|
|
@@ -128,9 +129,7 @@ | |
| ) | ||
|
|
||
| pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import() | ||
| pandas = ( | ||
| _versions_helpers.PANDAS_VERSIONS.try_import() | ||
| ) # mypy check fails because pandas import is outside module, there are type: ignore comments related to this | ||
| pandas = _versions_helpers.PANDAS_VERSIONS.try_import() # mypy check fails because pandas import is outside module, there are type: ignore comments related to this | ||
|
|
||
|
|
||
| ResumableTimeoutType = Union[ | ||
|
|
@@ -148,7 +147,7 @@ | |
| _RESUMABLE_URL_TEMPLATE = _BASE_UPLOAD_TEMPLATE + "resumable" | ||
| _GENERIC_CONTENT_TYPE = "*/*" | ||
| _READ_LESS_THAN_SIZE = ( | ||
| "Size {:d} was specified but the file-like object only had " "{:d} bytes remaining." | ||
| "Size {:d} was specified but the file-like object only had {:d} bytes remaining." | ||
| ) | ||
| _NEED_TABLE_ARGUMENT = ( | ||
| "The table argument should be a table ID string, Table, or TableReference" | ||
|
|
@@ -641,9 +640,16 @@ def _ensure_bqstorage_client( | |
| pandas_gbq = None # type: ignore | ||
|
|
||
| if pandas_gbq is None: | ||
| user_agent = "pandas-gbq/0.0.0" | ||
| # Even if pandas-gbq isn't installed, attribute all | ||
| # to_dataframe/to_arrow usage the same as we do the recommended | ||
| # (pandas-gbq) code paths. | ||
| pandas_user_agent = "pandas-gbq/0.0.0" | ||
| else: | ||
| user_agent = f"pandas-gbq/{pandas_gbq.__version__}" | ||
| pandas_user_agent = f"pandas-gbq/{pandas_gbq.__version__}" | ||
|
|
||
| # Track the google-cloud-bigquery version as "legacy" because this code | ||
| # path is intended to be migrated to pandas-gbq itself. | ||
| user_agent = f"legacy-gcb/{version.__version__} {pandas_user_agent}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| if client_info is None: | ||
| amended_client_info = google.api_core.gapic_v1.client_info.ClientInfo( | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing the
versionmodule asversioncan easily lead to shadowing issues or confusion becauseversionis a very common variable and parameter name throughout this codebase. Consider aliasing it tobq_versionto prevent potential naming conflicts.