Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for subqueries and variables within Firestore pipelines. Key additions include methods to convert pipelines into array or scalar expressions, a define stage for binding variables, and a subcollection source for relative path queries. New expression types like Variable and CurrentDocument were also implemented alongside corresponding system tests. Feedback was provided to add a type hint to the _PipelineValueExpression constructor to improve type safety and code clarity.
packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_expressions.py
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| return self._append(stages.Define(*aliased_expressions)) | ||
|
|
||
|
|
||
| class SubPipeline(_BasePipeline): |
There was a problem hiding this comment.
Is this being named Subpipeline to avoid name collision ? Is there an existing Subcollection class ?
Java calls this stage Subcollection https://github.com/googleapis/java-firestore/blob/0c8188520dfbada0d3fef0719e4f95fc231306be/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineSource.java#L214-L238
There was a problem hiding this comment.
This isn't a stage, it's a pipeline subclass. I think this is probably Python-specific, because of the weird way we have to handle async/sync code
In Python, we have 3 classes:
Pipelineto handle sync clientsAsyncPipelineto handle async clients_BasePipelineas a private class to handle common logic between the two.
Sub-pipelines presents a new use-case, where neither client is be attached, but it needs to be exposed to end-users
In Java and other implementations, it's much simpler, because there is a single pipeline class, and they just raise an exception if you try to use it to execute on a sub-pipeline.
| """ | ||
| return self._create_pipeline(stages.Literals(*documents)) | ||
|
|
||
| def subcollection(self, path: str) -> SubPipeline: |
There was a problem hiding this comment.
In java, this is static https://github.com/googleapis/java-firestore/blob/0c8188520dfbada0d3fef0719e4f95fc231306be/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineSource.java#L214-L238
Not sure what would be the equivalent in Python
There was a problem hiding this comment.
Good catch, I'll fix that
Add support for Pipeline subqueries, allowing users to perform complex data transformation by embedding a full pipeline inside another
New Stages:
definesubcollectionNew Expressions:
current_documentvariableget_fieldNew classes: