feat(firestore): support let stage#16030
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 introduces the 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 support for the let stage in Firestore pipelines, which is a great feature. The implementation looks solid, with new classes for the stage, methods on the pipeline builder, and thorough unit and system tests. I have a couple of suggestions: one to improve the clarity of the docstring for the new let method, and another to ensure deterministic behavior by sorting variables in the Let stage, following repository best practices.
| ... rating_plus_one=add(Field.of("rating"), 1), | ||
| ... has_awards=Field.of("awards").exists() | ||
| ... ) | ||
| >>> # Later stages can use Variable.of("rating_plus_one") |
There was a problem hiding this comment.
The docstring mentions Variable.of("rating_plus_one"), but the Variable class or a way to reference variables doesn't seem to be part of this pull request, as indicated by the TODO item add variable_field_reference. To avoid confusion and documenting a feature that is not yet available, it would be better to remove this line. The preceding sentences already explain that variables can be used in subsequent stages.
|
|
||
| def __init__(self, **variables: Expression): | ||
| super().__init__("let") | ||
| self.variables = variables |
There was a problem hiding this comment.
To ensure deterministic output for __repr__ and protobuf serialization, it's a good practice to sort the variables. This aligns with the general principle of producing predictable output, which is especially helpful for testing. You can sort the variables by key when they are assigned in the constructor.
| self.variables = variables | |
| self.variables = dict(sorted(variables.items())) |
References
- To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it (e.g., using
dict(sorted(metadata.items()))) instead of relying on manual ordering in the code.
TODO: