Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f9b65f
chore: updated gapic layer for execute_query
daniel-sanche May 8, 2025
dc808b5
Merge branch 'main' into pipeline_queries_approved
daniel-sanche Jun 9, 2025
17e71b9
feat: add pipelines structure (#1046)
daniel-sanche Jun 17, 2025
646c32f
Merge branch 'main' into pipeline_queries_approved
daniel-sanche Jun 23, 2025
6e06336
feat: add primary pipeline stages (#1048)
daniel-sanche Jul 16, 2025
5fde194
chore: Merge branch 'main' into pipeline_queries_approved
daniel-sanche Oct 17, 2025
cd578c1
chore: update and refactor pipeline expressions (#1111)
daniel-sanche Oct 22, 2025
fed7af2
feat: query to pipeline conversion (#1071)
daniel-sanche Oct 23, 2025
643f014
feat: Additional Pipeline Expressions (#1115)
daniel-sanche Oct 29, 2025
c62f3d9
chore: improve pipelines tests (#1116)
daniel-sanche Oct 30, 2025
b5b0bd7
chore: Pipeline queries cleanup (#1118)
daniel-sanche Oct 30, 2025
9a35dfe
feat: replace_with pipeline stage (#1121)
daniel-sanche Oct 31, 2025
8e83a40
chore: remove is_nan and is_null (#1123)
daniel-sanche Nov 6, 2025
b77002d
feat: pipelines create_from() (#1124)
daniel-sanche Nov 7, 2025
aef4391
feat: pipeline read time (#1125)
daniel-sanche Nov 7, 2025
2d3ed73
feat: improve pipeline expressions (#1126)
daniel-sanche Nov 11, 2025
4848fbe
feat: pipeline explain stats and index mode (#1128)
daniel-sanche Nov 11, 2025
18dfc6a
chore: update docstring for pipelines array (#1129)
daniel-sanche Dec 16, 2025
59fa92a
implemented cursors
daniel-sanche Jan 7, 2026
f9687a0
add unit tests
daniel-sanche Jan 7, 2026
c8d3cec
added more verify pipeline lines to system tests
daniel-sanche Jan 7, 2026
5ea1410
Merge branch 'pipeline-preview' into pipeline_cursors
daniel-sanche Jan 7, 2026
326315a
re-ordered sort
daniel-sanche Jan 7, 2026
1b518a8
improved test
daniel-sanche Jan 7, 2026
edc857b
match node implementation
daniel-sanche Jan 7, 2026
8026ced
chore: import main back into pipeline_preview branch
daniel-sanche Jan 9, 2026
631bda8
updated filtered warnings
daniel-sanche Jan 9, 2026
4ee909a
removed duplicate _BaseExecutePipeline
daniel-sanche Jan 10, 2026
86e1592
updated docstrings
daniel-sanche Jan 13, 2026
7632b85
Merge branch 'pipeline-preview-public' into pipeline_cursors
daniel-sanche Jan 13, 2026
8b0ee6c
Merge branch 'main' into pipeline_cursors
daniel-sanche Jan 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions google/cloud/firestore_v1/base_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,69 @@ def _cursor_pb(cursor_pair: Optional[Tuple[list, bool]]) -> Optional[Cursor]:
return None


def _where_conditions_from_cursor(
cursor: Tuple[List, bool],
orderings: List[pipeline_expressions.Ordering],
is_start_cursor: bool,
) -> pipeline_expressions.BooleanExpression:
"""
Converts a cursor into a filter condition for the pipeline.

Args:
cursor: The cursor values and the 'before' flag.
orderings: The list of ordering expressions used in the query.
is_start_cursor: True if this is a start_at/start_after cursor, False if it is an end_at/end_before cursor.
Returns:
A BooleanExpression representing the cursor condition.
"""
cursor_values, before = cursor
size = len(cursor_values)

if is_start_cursor:
filter_func = pipeline_expressions.Expression.greater_than
else:
filter_func = pipeline_expressions.Expression.less_than

field = orderings[size - 1].expr
value = pipeline_expressions.Constant(cursor_values[size - 1])

# Add condition for last bound
condition = filter_func(field, value)

if (is_start_cursor and before) or (not is_start_cursor and not before):
# When the cursor bound is inclusive, then the last bound
# can be equal to the value, otherwise it's not equal
condition = pipeline_expressions.Or(condition, field.equal(value))

# Iterate backwards over the remaining bounds, adding a condition for each one
for i in range(size - 2, -1, -1):
field = orderings[i].expr
value = pipeline_expressions.Constant(cursor_values[i])

# For each field in the orderings, the condition is either
# a) lessThan|greaterThan the cursor value,
# b) or equal the cursor value and lessThan|greaterThan the cursor values for other fields
condition = pipeline_expressions.Or(
filter_func(field, value),
pipeline_expressions.And(field.equal(value), condition),
)

return condition


def _reverse_orderings(
orderings: List[pipeline_expressions.Ordering],
) -> List[pipeline_expressions.Ordering]:
reversed_orderings = []
for o in orderings:
if o.order_dir == pipeline_expressions.Ordering.Direction.ASCENDING:
new_dir = "descending"
else:
new_dir = "ascending"
reversed_orderings.append(pipeline_expressions.Ordering(o.expr, new_dir))
return reversed_orderings


def _query_response_to_snapshot(
response_pb: RunQueryResponse, collection, expected_prefix: str
) -> Optional[document.DocumentSnapshot]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ def __init__(
If a Callable is given, it will be called with the same set of initialization
arguments as used in the FirestoreTransport constructor.
If set to None, a transport is chosen automatically.
NOTE: "rest" transport functionality is currently in a
beta state (preview). We welcome your feedback via an
issue in this library's source repository.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
Custom options for the client.

Expand Down
3 changes: 3 additions & 0 deletions google/cloud/firestore_v1/services/firestore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ def __init__(
If a Callable is given, it will be called with the same set of initialization
arguments as used in the FirestoreTransport constructor.
If set to None, a transport is chosen automatically.
NOTE: "rest" transport functionality is currently in a
beta state (preview). We welcome your feedback via an
issue in this library's source repository.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
Custom options for the client.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -994,14 +994,9 @@ def __init__(
) -> None:
"""Instantiate the transport.

Args:
host (Optional[str]):
The hostname to connect to (default: 'firestore.googleapis.com').
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
NOTE: This REST transport functionality is currently in a beta
state (preview). We welcome your feedback via a GitHub issue in
this library's repository. Thank you!

credentials_file (Optional[str]): Deprecated. A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
Expand Down
Loading
Loading