Skip to content

feat: add arithmetic expressions#2333

Merged
yvonnep165 merged 4 commits intomainfrom
yvonne/arithmetic-expressions
Mar 3, 2026
Merged

feat: add arithmetic expressions#2333
yvonnep165 merged 4 commits intomainfrom
yvonne/arithmetic-expressions

Conversation

@yvonnep165
Copy link
Contributor

Adds support for the arithmetic pipeline expressions: rand and trunc.

ported from firebase/firebase-js-sdk#9498

@yvonnep165 yvonnep165 requested review from a team as code owners March 2, 2026 15:56
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: firestore Issues related to the googleapis/java-firestore API. labels Mar 2, 2026
@yvonnep165 yvonnep165 requested review from dlarocque and milaGGL March 2, 2026 15:57
@yvonnep165 yvonnep165 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 2, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 2, 2026
/**
* Creates an expression that truncates this numeric expression to an integer.
*
* @return A new {@link Expression} representing an integer result from the trunc operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these docs explain that trunc and truncToPrecision return different values:
trunc returns an expression that represents the integer result from the trunc operation.
truncToPrecision returns an expression representing the trunc operation.

Which of these is true? Do these mean the same thing?

I noticed that round and roundToPrecision has the same docs inconsistency issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say both of them are true? trunc focuses on removing the value in the fractional part entirely, like for a float 3.9 the result is the "integer" 3.0, but equal to 3 (considered to be the same with the assertion libraries). truncToPrecision isn't returning a "whole number", like trunc(3.1415, 2) returns 3.14, considering as a trunc operation but result is not an integer. Just try to follow the doc from javascript and nodejs here. But I can change both of them to be returning the trunc operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But yea "representing a integer" can be a bit misleading. I removed this part.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Mar 2, 2026
@dlarocque dlarocque self-requested a review March 2, 2026 21:14
@yvonnep165 yvonnep165 removed the request for review from a team March 3, 2026 20:04
@yvonnep165 yvonnep165 merged commit 491c211 into main Mar 3, 2026
28 checks passed
@yvonnep165 yvonnep165 deleted the yvonne/arithmetic-expressions branch March 3, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/java-firestore API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants