Skip to content

feat(firestore): Add array expressions#9492

Open
milaGGL wants to merge 7 commits intomainfrom
mila/expressions-array
Open

feat(firestore): Add array expressions#9492
milaGGL wants to merge 7 commits intomainfrom
mila/expressions-array

Conversation

@milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Feb 11, 2026

Add new array expressions arrayFirst, arrayFirstN,arrayLast,arrayLastN,arrayMinimum,arrayMinimumN,arrayMaximum,arrayMaximumN,arrayFilter,arraySlice,arrayIndexOf, arrayLastIndexOf,arrayIndexOfAll.

NOTE: Do not merge as arrayFilter needs to be updated.

@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2026

⚠️ No Changeset found

Latest commit: d0c864c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @milaGGL, 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 expands the array processing capabilities within the Firestore SDK by adding eight new expressions. These functions provide developers with enhanced tools to extract specific elements (first, last, or a specified number of elements) and calculate statistical values (minimum, maximum, or a specified number of min/max elements) directly from arrays within their data pipelines, streamlining array-based data transformations.

Highlights

  • New Array Expressions: Eight new array manipulation functions have been introduced: arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN.
  • API and Documentation Updates: The API definitions and documentation for both firestore-lite and full Firestore pipelines have been updated to include these new expressions.
  • Comprehensive Testing: Integration and lite-mode tests have been added to ensure the correct functionality of all new array expressions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • common/api-review/firestore-lite-pipelines.api.md
    • Added API definitions for arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN.
  • common/api-review/firestore-pipelines.api.md
    • Added API definitions for arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN.
  • docs-devsite/firestore_lite_pipelines.expression.md
    • Documented the new arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN expressions with signatures and examples.
  • docs-devsite/firestore_pipelines.expression.md
    • Documented the new arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN expressions with signatures and examples.
  • packages/firestore/lite/pipelines/pipelines.ts
    • Exported the newly implemented array functions.
  • packages/firestore/src/api_pipelines.ts
    • Exported the newly implemented array functions from the lite-api expressions.
  • packages/firestore/src/lite-api/expressions.ts
    • Implemented the arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN methods on the Expression class and as standalone functions.
  • packages/firestore/test/integration/api/pipeline.test.ts
    • Added integration tests to verify the functionality of arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN.
  • packages/firestore/test/lite/pipeline.test.ts
    • Added lite-mode tests to verify the functionality of arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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 eight new array expression functions to Firestore pipelines, enhancing the query capabilities for array fields. The new functions are arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN. The changes are well-implemented and include corresponding API definitions, documentation, and comprehensive tests. I have identified a few areas for improvement, primarily concerning API documentation consistency and formatting in the generated documentation files.

@milaGGL milaGGL changed the title add 8 new expressions feat(firestore): Add array expressions Feb 12, 2026
@milaGGL milaGGL marked this pull request as ready for review February 13, 2026 15:21
@milaGGL milaGGL requested review from a team as code owners February 13, 2026 15:21
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 PR introduces a comprehensive set of new array expressions for Firestore pipelines, including functions for filtering, slicing, and finding elements within arrays. The implementation is well-tested with extensive integration tests. My feedback is primarily focused on improving the accuracy and consistency of the documentation for these new features to ensure clarity for developers. I've pointed out a few places where examples are missing or descriptions of return values could be more precise based on the test cases.

@milaGGL
Copy link
Contributor Author

milaGGL commented Feb 13, 2026

/gemini review

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 a comprehensive set of new array expressions to Firestore pipelines, which is a great feature enhancement. The implementation and tests are thorough. My feedback is mainly focused on improving code organization, documentation clarity, and minor code simplification for better maintainability. I've pointed out some redundant function calls, suggested reordering of exports and methods for consistency, and highlighted some areas in the documentation that could be confusing for users due to duplicated entries and incorrect links.

arrayIndexOf,
arrayLastIndexOf,
arrayIndexOfAll,
arrayFilter
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i think these should be grouped with the other array exports.


// @beta
export function arrayFilter(fieldName: string, variable: string, predicate: Expression): FunctionExpression;
export function arrayFilter(fieldName: string, variable: string, predicate: BooleanExpression): FunctionExpression;
Copy link
Contributor

Choose a reason for hiding this comment

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

What about naming the variable alias in arrayFilter? It may not matter much in the JS SDK, but it would be helpful when porting to Swift, since it would become a labeled parameter there. https://www.hackingwithswift.com/sixty/5/4/parameter-labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants