Skip to content

Conversation

Genesis929
Copy link
Contributor

@Genesis929 Genesis929 commented Aug 12, 2025

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2261🦕

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery API. labels Aug 12, 2025
@Genesis929 Genesis929 changed the title feat: add created/started/ended attribute to RowIterator. feat: add created/started/ended properties to RowIterator. Aug 12, 2025
"""Datetime at which the job was created.

See:
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobStatistics.FIELDS.creation_time
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@Genesis929 Genesis929 Aug 12, 2025

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.

@Genesis929 Genesis929 marked this pull request as ready for review August 12, 2025 21:02
@Genesis929 Genesis929 requested review from a team as code owners August 12, 2025 21:02
@Genesis929 Genesis929 requested a review from Neenu1995 August 12, 2025 21:02
@Genesis929 Genesis929 requested a review from tswast August 12, 2025 21:02
@Genesis929 Genesis929 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 13, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 13, 2025
@Linchin Linchin added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Aug 13, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Aug 13, 2025
Genesis929 and others added 6 commits August 13, 2025 13:48
Comment on lines 892 to 894
job_resource_done["statistics"]["query"]["creationTime"] = str(1437767599006)
job_resource_done["statistics"]["query"]["startTime"] = str(1437767600007)
job_resource_done["statistics"]["query"]["endTime"] = str(1437767601008)
Copy link
Contributor

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)
        )
    )

Comment on lines 977 to 979
self.assertEqual(result.created.timestamp() * 1000, 1437767599006)
self.assertEqual(result.started.timestamp() * 1000, 1437767600007)
self.assertEqual(result.ended.timestamp() * 1000, 1437767601008)
Copy link
Contributor

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.

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Thanks!

@tswast tswast merged commit 0a95b24 into googleapis:main Aug 14, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Job Lifecycle Timestamps (created, started, ended) on RowIterator
5 participants