-
Notifications
You must be signed in to change notification settings - Fork 319
feat: add created/started/ended properties to RowIterator. #2260
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
Conversation
google/cloud/bigquery/query.py
Outdated
"""Datetime at which the job was created. | ||
|
||
See: | ||
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobStatistics.FIELDS.creation_time |
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.
I don't think this is available on the Query response object, is it?
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.
Please update the link to the correct object: http://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query#body.QueryResponse.FIELDS.creation_time
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.
Thanks! Didn't notice the difference. Updated.
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
Co-authored-by: Tim Sweña (Swast) <[email protected]>
tests/unit/job/test_query.py
Outdated
job_resource_done["statistics"]["query"]["creationTime"] = str(1437767599006) | ||
job_resource_done["statistics"]["query"]["startTime"] = str(1437767600007) | ||
job_resource_done["statistics"]["query"]["endTime"] = str(1437767601008) |
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.
To make the assertions easier, use datetime objects and a helper function like I added in #2250
def _to_millis(dt: datetime.datetime) -> str:
return str(
int(
(dt - datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc))
/ datetime.timedelta(milliseconds=1)
)
)
tests/unit/job/test_query.py
Outdated
self.assertEqual(result.created.timestamp() * 1000, 1437767599006) | ||
self.assertEqual(result.started.timestamp() * 1000, 1437767600007) | ||
self.assertEqual(result.ended.timestamp() * 1000, 1437767601008) |
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.
I would recommend avoiding the cast to float of using timestamp()
, this can introduce rounding errors.
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.
Thanks!
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #2261🦕