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

ENH: Add max_results kwarg to read_gbq #34641

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

JohnPaton
Copy link
Contributor

@JohnPaton JohnPaton commented Jun 8, 2020

Adds support for the new max_results kwarg from pandas-gbq (added in 0.12.0). Since max_results is a new kwarg, it is handled and tested in the same way as the use_bqstorage_api kwarg to maintain backwards compatibility.

Open question: Setting max_results=0 causes pandas_gbq.read_gbq to return None instead of a DataFrame. I've kept this behaviour the same in this PR, but maintainers may prefer to always return a (empty) DataFrame instead of None.

Since max_results is a new kwarg (added in pandas-gbq 0.12.0), it
is handled and tested in the same way as use_bqstorage_api,
using the "new kwargs" mechanism to maintain backwards
compatibility with older pandas-gbq versions.
Comment on lines +129 to +131
max_results : int, optional
If set, limit the maximum number of rows to fetch from the query
results.
Copy link
Contributor Author

@JohnPaton JohnPaton Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied the docstring from pandas-gbq here, but given the current behaviour it might be an idea to add a line like

If set to 0, ``read_gbq`` will return ``None`` once the query has 
executed.

@WillAyd
Copy link
Member

WillAyd commented Jun 9, 2020

@tswast

@jreback jreback added this to the 1.1 milestone Jun 9, 2020
@jreback jreback merged commit b024e93 into pandas-dev:master Jun 9, 2020
@jreback
Copy link
Contributor

jreback commented Jun 9, 2020

thanks @JohnPaton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add max_results to read_gbq
5 participants