Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions google/cloud/firestore_v1/_pipeline_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
from google.cloud.firestore_v1.vector import Vector
from google.cloud.firestore_v1.base_vector_query import DistanceMeasure
from google.cloud.firestore_v1.pipeline_expressions import (
Accumulator,
AggregateFunction,
Expr,
ExprWithAlias,
AliasedAggregate,
AliasedExpr,
Field,
FilterCondition,
BooleanExpr,
Selectable,
Ordering,
)
Expand Down Expand Up @@ -164,8 +165,8 @@ class Aggregate(Stage):

def __init__(
self,
*args: ExprWithAlias[Accumulator],
accumulators: Sequence[ExprWithAlias[Accumulator]] = (),
*args: AliasedExpr[AggregateFunction],
accumulators: Sequence[AliasedAggregate] = (),
groups: Sequence[str | Selectable] = (),
):
super().__init__()
Expand Down Expand Up @@ -459,7 +460,7 @@ def _pb_options(self):
class Where(Stage):
"""Filters documents based on a specified condition."""

def __init__(self, condition: FilterCondition):
def __init__(self, condition: BooleanExpr):
super().__init__()
self.condition = condition

Expand Down
18 changes: 8 additions & 10 deletions google/cloud/firestore_v1/base_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
from google.cloud.firestore_v1.types.firestore import ExecutePipelineRequest
from google.cloud.firestore_v1.pipeline_result import PipelineResult
from google.cloud.firestore_v1.pipeline_expressions import (
Accumulator,
Expr,
ExprWithAlias,
Field,
FilterCondition,
BooleanExpr,
Selectable,
)
from google.cloud.firestore_v1 import _helpers
Expand Down Expand Up @@ -220,14 +218,14 @@ def select(self, *selections: str | Selectable) -> "_BasePipeline":
"""
return self._append(stages.Select(*selections))

def where(self, condition: FilterCondition) -> "_BasePipeline":
def where(self, condition: BooleanExpr) -> "_BasePipeline":
"""
Filters the documents from previous stages to only include those matching
the specified `FilterCondition`.
the specified `BooleanExpr`.

This stage allows you to apply conditions to the data, similar to a "WHERE"
clause in SQL. You can filter documents based on their field values, using
implementations of `FilterCondition`, typically including but not limited to:
implementations of `BooleanExpr`, typically including but not limited to:
- field comparators: `eq`, `lt` (less than), `gt` (greater than), etc.
- logical operators: `And`, `Or`, `Not`, etc.
- advanced functions: `regex_matches`, `array_contains`, etc.
Expand All @@ -252,7 +250,7 @@ def where(self, condition: FilterCondition) -> "_BasePipeline":


Args:
condition: The `FilterCondition` to apply.
condition: The `BooleanExpr` to apply.

Returns:
A new Pipeline object with this stage appended to the stage list
Expand Down Expand Up @@ -579,7 +577,7 @@ def limit(self, limit: int) -> "_BasePipeline":

def aggregate(
self,
*accumulators: ExprWithAlias[Accumulator],
*accumulators: AliasedAggregate,
groups: Sequence[str | Selectable] = (),
) -> "_BasePipeline":
"""
Expand All @@ -589,7 +587,7 @@ def aggregate(
This stage allows you to calculate aggregate values (like sum, average, count,
min, max) over a set of documents.

- **Accumulators:** Define the aggregation calculations using `Accumulator`
- **AggregateFunctions:** Define the aggregation calculations using `AggregateFunction`
expressions (e.g., `sum()`, `avg()`, `count()`, `min()`, `max()`) combined
with `as_()` to name the result field.
- **Groups:** Optionally specify fields (by name or `Selectable`) to group
Expand Down Expand Up @@ -617,7 +615,7 @@ def aggregate(


Args:
*accumulators: One or more `ExprWithAlias[Accumulator]` expressions defining
*accumulators: One or more `AliasedAggregate` expressions defining
the aggregations to perform and their output names.
groups: An optional sequence of field names (str) or `Selectable`
expressions to group by before aggregating.
Expand Down
Loading