This repository was archived by the owner on Mar 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
feat: Added read_time as a parameter to various calls (synchronous/base classes) #1013
Closed
Closed
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ffae9bc
feat: Added read_time as a parameter to various calls (synchronous/base
gkevinzheng 0bc5302
Added system test for DocumentReference.collections
gkevinzheng e9eefd6
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] a1d8030
linting
gkevinzheng d551aa2
Conditionally adding read_time to kwargs for cleaner test separation
gkevinzheng 3151b8b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 4e6f95e
Conditionally adding read_time to kwargs in base_aggregation.py
gkevinzheng 2ed7eb5
More conditionally adding read_time to kwargs
gkevinzheng 402fe49
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 39ae878
Added tests for collections.get/stream
gkevinzheng d85f2f0
linting
gkevinzheng a8ced8f
Addressed review feedback
gkevinzheng f19995e
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 7f99200
linting
gkevinzheng 6f5b1c4
chore: update protoplus for python 3.13 (#1009)
daniel-sanche 0652cbc
fix: bump default deadline on CreateDatabase and RestoreDatabase to 2…
gcf-owl-bot[bot] fbd6ab2
fix: client-side path validation for batch.update (#1021)
daniel-sanche 33c134b
fix: Watch thread deadlock on exit (#1014)
daniel-sanche 4d24a95
chore(python): fix typo in README (#1015)
gcf-owl-bot[bot] 029fcfb
chore(python): conditionally load credentials in .kokoro/build.sh (#1…
gcf-owl-bot[bot] e6bc31d
chore: add logging section to readme (#1018)
gcf-owl-bot[bot] d8ae170
chore: pull up gapic updates (#1016)
gcf-owl-bot[bot] 1fcb218
chore(main): release 2.20.1 (#1011)
release-please[bot] 1a08c4b
chore: Update gapic-generator-python to v1.23.2 (#1024)
gcf-owl-bot[bot] f71aba8
chore: remove unused files (#1027)
parthea 17668b7
fix: allow Protobuf 6.x (#1028)
parthea 79a4a88
chore: Update gapic-generator-python to 1.23.6 (#1032)
gcf-owl-bot[bot] 4061cf7
fix: remove setup.cfg configuration for creating universal wheels (#1…
parthea 5957feb
chore(docs): add BulkWriter to docs (#1033)
daniel-sanche e5e416a
chore(python): fix incorrect import statement in README (#1034)
gcf-owl-bot[bot] 79cfc5d
chore(python): remove .gitignore from templates (#1036)
gcf-owl-bot[bot] 32e729d
chore(python): remove CONTRIBUTING.rst from templates (#1038)
gcf-owl-bot[bot] 4c69636
chore(python): remove noxfile.py from templates (#1041)
gcf-owl-bot[bot] d51ac35
chore(main): release 2.20.2 (#1031)
release-please[bot] c0606e2
feat: Added read_time as a parameter to various calls (synchronous/base
gkevinzheng 6b1bb42
Fixed unit tests
gkevinzheng e33292c
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| """ | ||
| from __future__ import annotations | ||
|
|
||
| from datetime import datetime | ||
| from typing import TYPE_CHECKING, Any, Generator, List, Optional, Union | ||
|
|
||
| from google.api_core import exceptions, gapic_v1 | ||
|
|
@@ -56,6 +57,7 @@ def get( | |
| timeout: float | None = None, | ||
| *, | ||
| explain_options: Optional[ExplainOptions] = None, | ||
| read_time: Optional[datetime] = None, | ||
| ) -> QueryResultsList[AggregationResult]: | ||
| """Runs the aggregation query. | ||
|
|
||
|
|
@@ -78,6 +80,10 @@ def get( | |
| (Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]): | ||
| Options to enable query profiling for this query. When set, | ||
| explain_metrics will be available on the returned generator. | ||
| read_time (Optional[datetime]): If set, reads documents as they were at the given | ||
| time. This must be a microsecond precision timestamp within the past one hour, | ||
| or if Point-in-Time Recovery is enabled, can additionally be a whole minute | ||
| timestamp within the past 7 days. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple questions:
|
||
|
|
||
| Returns: | ||
| QueryResultsList[AggregationResult]: The aggregation query results. | ||
|
|
@@ -90,6 +96,7 @@ def get( | |
| retry=retry, | ||
| timeout=timeout, | ||
| explain_options=explain_options, | ||
| read_time=read_time, | ||
| ) | ||
| result_list = list(result) | ||
|
|
||
|
|
@@ -100,13 +107,16 @@ def get( | |
|
|
||
| return QueryResultsList(result_list, explain_options, explain_metrics) | ||
|
|
||
| def _get_stream_iterator(self, transaction, retry, timeout, explain_options=None): | ||
| def _get_stream_iterator( | ||
| self, transaction, retry, timeout, explain_options=None, read_time=None | ||
| ): | ||
| """Helper method for :meth:`stream`.""" | ||
| request, kwargs = self._prep_stream( | ||
| transaction, | ||
| retry, | ||
| timeout, | ||
| explain_options, | ||
| read_time, | ||
| ) | ||
|
|
||
| return self._client._firestore_api.run_aggregation_query( | ||
|
|
@@ -132,6 +142,7 @@ def _make_stream( | |
| retry: Union[retries.Retry, None, object] = gapic_v1.method.DEFAULT, | ||
| timeout: Optional[float] = None, | ||
| explain_options: Optional[ExplainOptions] = None, | ||
| read_time: Optional[datetime] = None, | ||
| ) -> Generator[List[AggregationResult], Any, Optional[ExplainMetrics]]: | ||
| """Internal method for stream(). Runs the aggregation query. | ||
|
|
||
|
|
@@ -155,6 +166,10 @@ def _make_stream( | |
| (Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]): | ||
| Options to enable query profiling for this query. When set, | ||
| explain_metrics will be available on the returned generator. | ||
| read_time (Optional[datetime]): If set, reads documents as they were at the given | ||
| time. This must be a microsecond precision timestamp within the past one hour, | ||
| or if Point-in-Time Recovery is enabled, can additionally be a whole minute | ||
| timestamp within the past 7 days. | ||
|
|
||
| Yields: | ||
| List[AggregationResult]: | ||
|
|
@@ -172,6 +187,7 @@ def _make_stream( | |
| retry, | ||
| timeout, | ||
| explain_options, | ||
| read_time, | ||
| ) | ||
| while True: | ||
| try: | ||
|
|
@@ -182,6 +198,8 @@ def _make_stream( | |
| transaction, | ||
| retry, | ||
| timeout, | ||
| explain_options, | ||
| read_time, | ||
| ) | ||
| continue | ||
| else: | ||
|
|
@@ -206,6 +224,7 @@ def stream( | |
| timeout: Optional[float] = None, | ||
| *, | ||
| explain_options: Optional[ExplainOptions] = None, | ||
| read_time: Optional[datetime] = None, | ||
| ) -> StreamGenerator[List[AggregationResult]]: | ||
| """Runs the aggregation query. | ||
|
|
||
|
|
@@ -229,6 +248,10 @@ def stream( | |
| (Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]): | ||
| Options to enable query profiling for this query. When set, | ||
| explain_metrics will be available on the returned generator. | ||
| read_time (Optional[datetime]): If set, reads documents as they were at the given | ||
| time. This must be a microsecond precision timestamp within the past one hour, | ||
| or if Point-in-Time Recovery is enabled, can additionally be a whole minute | ||
| timestamp within the past 7 days. | ||
|
|
||
| Returns: | ||
| `StreamGenerator[List[AggregationResult]]`: | ||
|
|
@@ -239,5 +262,6 @@ def stream( | |
| retry=retry, | ||
| timeout=timeout, | ||
| explain_options=explain_options, | ||
| read_time=read_time, | ||
| ) | ||
| return StreamGenerator(inner_generator, explain_options) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: just importing datetime as a module is probably better? This import overrides the "datetime" module name with the class name, which would get a bit weird if we have to use other datetime imports in the future. And it makes some of the type annotations a bit ambiguous
But let me know what you think