Skip to content
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: tests fail due to missing progress_bar_type argument #296

Closed
tswast opened this issue Nov 25, 2019 · 1 comment · Fixed by #298
Closed

BUG: tests fail due to missing progress_bar_type argument #296

tswast opened this issue Nov 25, 2019 · 1 comment · Fixed by #298
Assignees
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tswast
Copy link
Collaborator

tswast commented Nov 25, 2019

Example test failure: https://circleci.com/gh/tswast/pandas-gbq/699?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

____ TestReadGBQIntegration.test_should_properly_handle_null_timestamp[env] ____

self = <tests.system.test_gbq.TestReadGBQIntegration object at 0x7f6326df4278>
project_id = '****************'

    def test_should_properly_handle_null_timestamp(self, project_id):
        query = "SELECT TIMESTAMP(NULL) AS null_timestamp"
        df = gbq.read_gbq(
            query,
            project_id=project_id,
            credentials=self.credentials,
>           dialect="legacy",
        )

tests/system/test_gbq.py:386: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas_gbq/gbq.py:1034: in read_gbq
    progress_bar_type=progress_bar_type,
pandas_gbq/gbq.py:532: in run_query
    progress_bar_type=progress_bar_type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pandas_gbq.gbq.GbqConnector object at 0x7f6326ddf2e8>
query_job = <google.cloud.bigquery.job.QueryJob object at 0x7f632259d630>
max_results = None, progress_bar_type = 'tqdm'

    def _download_results(
        self, query_job, max_results=None, progress_bar_type=None
    ):
        # No results are desired, so don't bother downloading anything.
        if max_results == 0:
            return None
    
        try:
            bqstorage_client = None
            if max_results is None:
                # Only use the BigQuery Storage API if the full result set is requested.
                bqstorage_client = _make_bqstorage_client(
                    self.use_bqstorage_api, self.credentials
                )
    
            query_job.result()
            # Get the table schema, so that we can list rows.
            destination = self.client.get_table(query_job.destination)
            rows_iter = self.client.list_rows(
                destination, max_results=max_results
            )
    
            schema_fields = [field.to_api_repr() for field in rows_iter.schema]
            nullsafe_dtypes = _bqschema_to_nullsafe_dtypes(schema_fields)
            df = rows_iter.to_dataframe(
                dtypes=nullsafe_dtypes,
                bqstorage_client=bqstorage_client,
>               progress_bar_type=progress_bar_type,
            )
E           TypeError: to_dataframe() got an unexpected keyword argument 'progress_bar_type'

pandas_gbq/gbq.py:562: TypeError

Older versions of the google-cloud-bigquery client don't have a progress_bar_type argument.

Proposed solution:

Detect if the minimum version of google-cloud-bigquery is installed and only then populate the progress_bar_type argument.

Alternatives considered:

  • Increment the minimum version of google-cloud-bigquery. As much as possible, we should allow any version of google-cloud-bigquery. The wider we can make the allowed package versions, the less likely it is that people will encounter version conflicts.
@tswast tswast self-assigned this Nov 25, 2019
@tswast tswast added priority: p0 Highest priority. Critical issue. P0 implies highest priority. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 25, 2019
@tswast
Copy link
Collaborator Author

tswast commented Nov 25, 2019

On second-thought. progress_bar_type was added in 1.11.0 https://googleapis.dev/python/bigquery/latest/changelog.html in April, 2019. There have been enough releases between now and then that I feel OK about incrementing the minimum version slightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p0 Highest priority. Critical issue. P0 implies highest priority. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant