Skip to content

feat(firestore): support array_agg(), array_agg_distinct(), first(), last()#16029

Open
Linchin wants to merge 3 commits intogoogleapis:mainfrom
Linchin:fs-funcs
Open

feat(firestore): support array_agg(), array_agg_distinct(), first(), last()#16029
Linchin wants to merge 3 commits intogoogleapis:mainfrom
Linchin:fs-funcs

Conversation

@Linchin
Copy link
Contributor

@Linchin Linchin commented Mar 5, 2026

TODO:

  • verify docstring

@Linchin Linchin requested review from a team as code owners March 5, 2026 00:47
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 significantly enhances the Firestore client library by introducing several new aggregation functions. These additions allow users to collect values into arrays, retrieve distinct values, and easily select the first or last elements within a dataset, thereby expanding the analytical capabilities of the query pipeline. The changes are thoroughly tested with both unit and system tests to ensure reliability.

Highlights

  • New Aggregation Functions: Added support for array_agg(), array_agg_distinct(), first(), and last() aggregation functions within the Firestore pipeline expressions, enabling more powerful data manipulation.
  • System Tests: Introduced comprehensive system-level end-to-end tests for the newly added aggregation functions to ensure their correct behavior in a real-world scenario.
  • Unit Tests: Implemented dedicated unit tests for each new aggregation method to verify their individual functionality and integration with the existing expression framework.
Changelog
  • packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_expressions.py
    • Added array_agg method to create an aggregation that collects values into an array.
    • Added array_agg_distinct method to create an aggregation that collects distinct values into an array.
    • Added first method to create an aggregation that selects the first value.
    • Added last method to create an aggregation that selects the last value.
  • packages/google-cloud-firestore/tests/system/pipeline_e2e/aggregates.yaml
    • Added a new system test testArrayAgg to verify the array_agg function.
    • Added a new system test testArrayAggDistinct to verify the array_agg_distinct function.
    • Added a new system test testFirst to verify the first function.
    • Added a new system test testLast to verify the last function.
  • packages/google-cloud-firestore/tests/unit/v1/test_pipeline_expressions.py
    • Added test_array_agg to validate the array_agg method's behavior.
    • Added test_array_agg_distinct to validate the array_agg_distinct method's behavior.
    • Added test_first to validate the first method's behavior.
    • Added test_last to validate the last method's behavior.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for array_agg(), array_agg_distinct(), first(), and last() aggregation functions. The changes include updates to pipeline expressions and the addition of corresponding unit and system tests. My review found a couple of minor grammatical errors in the docstrings, for which I've provided suggestions. These comments do not conflict with any of the provided rules and are therefore kept as is.

Linchin and others added 2 commits March 4, 2026 17:01
…line_expressions.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…line_expressions.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants