Skip to content

feat(firestore): add timestamp expressions#9728

Merged
yvonnep165 merged 8 commits intomainfrom
yvonne/timestamp-expressions
Mar 25, 2026
Merged

feat(firestore): add timestamp expressions#9728
yvonnep165 merged 8 commits intomainfrom
yvonne/timestamp-expressions

Conversation

@yvonnep165
Copy link
Copy Markdown
Contributor

@yvonnep165 yvonnep165 commented Mar 17, 2026

Add new timestamp expressions timestamp_diff and timestamp_extract and integration tests for the expressions

The expression timestamp_trunc was already ported in the repo with integration tests in firebase-js-sdk/packages/firestore/test/integration/api/pipeline.test.ts
Add extra integration tests for timestamp_trunc in firebase-js-sdk/packages/firestore/test/lite/pipeline.test.ts and amend the example usage documentation for standalone methods

Both timestamp_trunc and timestamp_extract use overload implementation and have timeZone as optional argument

@yvonnep165 yvonnep165 requested review from a team as code owners March 17, 2026 21:34
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: 6dd01c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
firebase Minor
@firebase/firestore Minor
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

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

@gemini-code-assist
Copy link
Copy Markdown
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 Firestore's data pipeline functionality by introducing two new timestamp expressions: timestamp_diff and timestamp_extract. These additions allow users to calculate the difference between two timestamps and extract specific components (like year, month, or hour) from a timestamp, with support for various time units and optional timezones. The changes also include updated documentation and expanded test coverage to ensure the reliability and usability of these new features.

Highlights

  • New Timestamp Expressions: Introduced timestamp_diff and timestamp_extract expressions to Firestore's pipeline capabilities, enabling advanced timestamp manipulation.
  • Enhanced Timestamp Truncation: Added extra integration tests for timestamp_trunc and amended its example usage documentation for standalone methods.
  • Flexible API Design: Both timestamp_diff and timestamp_extract expressions support overloaded implementations and an optional timeZone argument for greater flexibility.
  • Comprehensive Documentation: Updated API review files and developer documentation to reflect the new timestamp expressions and their usage.

🧠 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
  • .changeset/cool-dragons-compete.md
    • Added support for timestamp_trunc, timestamp_diff and timestamp_extract expressions.
  • common/api-review/firestore-lite-pipelines.api.md
    • Added timestampDiff and timestampExtract methods to the Expression class.
    • Defined the new TimePart type.
  • common/api-review/firestore-pipelines.api.md
    • Added timestampDiff and timestampExtract methods to the Expression class.
    • Defined the new TimePart type.
  • docs-devsite/firestore_lite_pipelines.expression.md
    • Updated documentation to include timestampDiff and timestampExtract methods for the Expression class.
  • docs-devsite/firestore_lite_pipelines.md
    • Updated documentation to list new timestampDiff and timestampExtract functions.
    • Defined the TimePart type.
    • Amended timestampTruncate examples for standalone methods.
  • docs-devsite/firestore_pipelines.expression.md
    • Updated documentation to include timestampDiff and timestampExtract methods for the Expression class.
  • docs-devsite/firestore_pipelines.md
    • Updated documentation to list new timestampDiff and timestampExtract functions.
    • Defined the TimePart type.
    • Amended timestampTruncate examples for standalone methods.
  • packages/firestore/lite/pipelines/pipelines.ts
    • Exported timestampDiff, timestampExtract, and TimePart.
  • packages/firestore/src/api_pipelines.ts
    • Exported timestampDiff, timestampExtract, and TimePart.
  • packages/firestore/src/lite-api/expressions.ts
    • Implemented timestampDiff and timestampExtract methods in the Expression class.
    • Defined the TimePart type.
    • Updated timestampTruncate function examples to use standalone methods.
  • packages/firestore/test/integration/api/pipeline.test.ts
    • Added integration tests for timestampDiff and timestampExtract expressions.
  • packages/firestore/test/lite/pipeline.test.ts
    • Added unit tests for timestampTruncate, timestampDiff, and timestampExtract expressions.
Activity
  • New timestamp_diff and timestamp_extract expressions were introduced.
  • Existing timestamp_trunc functionality received additional integration tests.
  • API definitions and developer documentation were updated to reflect the new features.
  • Comprehensive integration and unit tests were added for the new timestamp expressions.
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
Copy Markdown
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 timestamp_diff and timestamp_extract expressions for Firestore, enhancing its timestamp manipulation capabilities. The changes are well-implemented with corresponding API definitions, documentation, and both integration and lite tests. The documentation for timestamp_trunc examples has also been improved for consistency. My review found a minor inconsistency in the documentation that could be addressed.

Comment thread docs-devsite/firestore_lite_pipelines.expression.md Outdated
Comment thread docs-devsite/firestore_pipelines.expression.md Outdated
@yvonnep165 yvonnep165 requested review from dlarocque and milaGGL March 17, 2026 21:39
Comment thread packages/firestore/src/lite-api/expressions.ts
Comment thread packages/firestore/test/integration/api/pipeline.test.ts
Copy link
Copy Markdown
Contributor

@milaGGL milaGGL left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments

@yvonnep165 yvonnep165 requested review from hsubox76 and removed request for hsubox76 March 25, 2026 14:56
@yvonnep165 yvonnep165 merged commit 5cd6509 into main Mar 25, 2026
48 of 50 checks passed
@yvonnep165 yvonnep165 deleted the yvonne/timestamp-expressions branch March 25, 2026 16:19
yvonnep165 added a commit to firebase/firebase-android-sdk that referenced this pull request Mar 27, 2026
Add new timestamp expressions `timestamp_diff` and `timestamp_extract`
and integration tests for the expressions

The expression `timestamp_trunc` already existed in the repo with
integration tests.
Add methods for timestampTruncWithTimezone to avoid signature collision.
Add methods to allow timezone as parameter in chained expressions.
Amend the tests for the `timestamp_trunc` expression

Ported from firebase/firebase-js-sdk#9728
@google-oss-bot google-oss-bot mentioned this pull request Apr 8, 2026
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.

4 participants