-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
BigQuery: Complete the to_arrow() method feature request #8693
Conversation
The method signatures for to_arrow() and to_dataframe() methods in the job.QueryJob and table.RowIterator classes must match to present a consistent API for users.
inspect.signature() method is only available in older Python versions
@@ -2896,7 +2896,9 @@ def result(self, timeout=None, page_size=None, retry=DEFAULT_RETRY): | |||
rows._preserve_order = _contains_order_by(self.query) | |||
return rows | |||
|
|||
def to_arrow(self, progress_bar_type=None): | |||
# If changing the signature of this method, make sure to apply the same | |||
# changes to table.RowIterator.to_arrow() |
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.
Note - this and the other similar comments might be redundant now that we have a test for method signatures, but I personally don't mind having them, as it makes the contract between the two classes more explicit.
def test_to_arrow_method_signatures_match(query_job_class, row_iterator_class): | ||
sig = inspect.signature(query_job_class.to_arrow) | ||
sig2 = inspect.signature(row_iterator_class.to_arrow) | ||
assert sig == sig2 |
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.
Love this! ❤️ Thanks for the test. I wouldn't have thought to try this.
Closes #5204.
This PR adds the last missing piece of the feature, i.e. the
bqstorage_client
parameter that was still missing from one of the methods.How to test
Check that the signatures for various
to_arrow()
methods match (and the same for theto_dataframe()
methods).