-
Notifications
You must be signed in to change notification settings - Fork 122
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
BUG: Adapt to breaking change in google-cloud-bigquery 0.32.0.dev1 #152
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b3620a
BUG: Update pandas-gbq to latest version of google-cloud-bigquery
tswast 244d5f8
DOC: Changelog to indicate reason for deps upgrade.
tswast 3536cf4
DOC: Add verbose deprecation to changelog.
tswast 3110f8d
Detect google-cloud-bigquery version for backwards compatibility
tswast 3e34f58
pop
tswast 3919a1c
Add installed version arg
tswast 74952de
Add validation for old versions. Fix schema tests for old versions.
tswast c636448
Update changelog.
tswast 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 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
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
google-auth | ||
google-auth-oauthlib | ||
mock | ||
google-cloud-bigquery |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import pkg_resources | ||
from google.cloud import bigquery | ||
|
||
|
||
# Version with query config breaking change. | ||
BIGQUERY_CONFIG_VERSION = pkg_resources.parse_version('0.32.0.dev1') | ||
|
||
|
||
def query_config_old_version(resource): | ||
# Verify that we got a query resource. In newer versions of | ||
# google-cloud-bigquery enough of the configuration is passed on to the | ||
# backend that we can expect a backend validation error instead. | ||
if len(resource) != 1: | ||
raise ValueError("Only one job type must be specified, but " | ||
"given {}".format(','.join(resource.keys()))) | ||
if 'query' not in resource: | ||
raise ValueError("Only 'query' job type is supported") | ||
return bigquery.QueryJobConfig.from_api_repr(resource['query']) | ||
|
||
|
||
def query_config(resource, installed_version): | ||
if installed_version < BIGQUERY_CONFIG_VERSION: | ||
return query_config_old_version(resource) | ||
return bigquery.QueryJobConfig.from_api_repr(resource) |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
import pkg_resources | ||
|
||
import mock | ||
|
||
|
||
@mock.patch('google.cloud.bigquery.QueryJobConfig') | ||
def test_query_config_w_old_bq_version(mock_config): | ||
from pandas_gbq._query import query_config | ||
|
||
old_version = pkg_resources.parse_version('0.29.0') | ||
query_config({'query': {'useLegacySql': False}}, old_version) | ||
mock_config.from_api_repr.assert_called_once_with({'useLegacySql': False}) | ||
|
||
|
||
@mock.patch('google.cloud.bigquery.QueryJobConfig') | ||
def test_query_config_w_dev_bq_version(mock_config): | ||
from pandas_gbq._query import query_config | ||
|
||
dev_version = pkg_resources.parse_version('0.32.0.dev1') | ||
query_config( | ||
{ | ||
'query': { | ||
'useLegacySql': False, | ||
}, | ||
'labels': {'key': 'value'}, | ||
}, | ||
dev_version) | ||
mock_config.from_api_repr.assert_called_once_with( | ||
{ | ||
'query': { | ||
'useLegacySql': False, | ||
}, | ||
'labels': {'key': 'value'}, | ||
}) | ||
|
||
|
||
@mock.patch('google.cloud.bigquery.QueryJobConfig') | ||
def test_query_config_w_new_bq_version(mock_config): | ||
from pandas_gbq._query import query_config | ||
|
||
dev_version = pkg_resources.parse_version('1.0.0') | ||
query_config( | ||
{ | ||
'query': { | ||
'useLegacySql': False, | ||
}, | ||
'labels': {'key': 'value'}, | ||
}, | ||
dev_version) | ||
mock_config.from_api_repr.assert_called_once_with( | ||
{ | ||
'query': { | ||
'useLegacySql': False, | ||
}, | ||
'labels': {'key': 'value'}, | ||
}) |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ def readme(): | |
|
||
|
||
INSTALL_REQUIRES = [ | ||
'setuptools', | ||
'pandas', | ||
'google-auth', | ||
'google-auth-oauthlib', | ||
|
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.
much nicer