feat(firestore): literals pipeline stage#16028
feat(firestore): literals pipeline stage#16028Linchin wants to merge 1 commit intogoogleapis:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Firestore client library by introducing a new Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new literals pipeline stage, which allows specifying a fixed set of documents as the starting point of a pipeline. The implementation includes the literals method on the pipeline builder, the Literals stage class, and corresponding unit and end-to-end tests. My review focuses on improving the clarity and correctness of the type hints and docstrings for the new functionality. I've suggested changes to make the API easier to understand and use correctly.
| stages.FindNearest(field, vector, distance_measure, options) | ||
| ) | ||
|
|
||
| def literals(self, *documents: str | Selectable) -> "_BasePipeline": |
There was a problem hiding this comment.
The type hint for *documents is incomplete. It should include dict as documents are often passed as dictionaries, which is not covered by str | Selectable.
| def literals(self, *documents: str | Selectable) -> "_BasePipeline": | |
| def literals(self, *documents: dict | str | Selectable) -> "_BasePipeline": |
| documents: A `str` or `Selectable` expression. If a `str`, it's | ||
| treated as a field path to an array of documents. | ||
| If a `Selectable`, it's usually a `Constant` | ||
| containing an array of documents (as dictionaries). |
There was a problem hiding this comment.
The Args section of the docstring is misleading. It describes a single argument, but the method accepts *documents. It also incorrectly states that a str is treated as a field path; the implementation treats it as a string literal. To use a field path, field() should be used explicitly.
| documents: A `str` or `Selectable` expression. If a `str`, it's | |
| treated as a field path to an array of documents. | |
| If a `Selectable`, it's usually a `Constant` | |
| containing an array of documents (as dictionaries). | |
| documents: One or more documents to be returned by this stage. | |
| Each can be a `dict`, a `str` literal, or a | |
| `Selectable` expression (e.g. `field("path")` or | |
| `Constant.of(...)`). |
| class Literals(Stage): | ||
| """Returns documents from a fixed set of predefined document objects.""" | ||
|
|
||
| def __init__(self, *documents: str | Selectable): |
There was a problem hiding this comment.
Succeeding googleapis/python-firestore#1170 for the monorepo migration.