-
Notifications
You must be signed in to change notification settings - Fork 304
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
feat: search statistics #1616
feat: search statistics #1616
Conversation
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.
Good start on the basic structure. This is an output-only stat so no need for a setter, but we'll need all the unit testing and a similar IT test to java using a query that invokes the search()
sql function.
google/cloud/bigquery/job/query.py
Outdated
"""docstring""" | ||
|
||
stats = self._job_statistics().get("searchStatistics") | ||
return SearchStats.from_api_repr(stats) |
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.
need to handle the not-present case, e.g. if stats is not None:
google/cloud/bigquery/job/query.py
Outdated
|
||
@classmethod | ||
def from_api_repr(cls, stats: Dict[str, Any]): | ||
mode = stats.get("indexUsageMode", "INDEX_USAGE_MODE_UNSPECIFIED") |
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.
Generally, we want to avoid the library injecting values not present in the API response, so returning the default value here may not be more desirable than empty/none.
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.
After some more reading, I think the attribute approach is sufficient vs explicit property annotations.
Main concern is about attribute defaults. Typically None is better when users are trying to disambiguate between presence of a value vs the empty value, but happy to talk about this more. Swapping the default impacts typing, unit tests, etc.
Adds a feature to display search statistics in support of the following customer request: https://buganizer.corp.google.com/issues/290679162
Includes several classes to encapsulate the data found here:
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#searchstatistics
Also includes a function to access the data in the classes.