feat: Add Rand and Trunc expressions#16037
Conversation
Rand and Trunc expressionRand and Trunc expressions
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 enhances the Firestore client library by introducing a new Highlights
Changelog
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 adds a Rand expression for Firestore pipelines, along with corresponding unit and system tests. The implementation of the Rand expression itself looks good.
However, I found a logical flaw in the system test for Rand, where it uses two separate calls to Rand() to check if the value is within a range, which doesn't guarantee that a single random number is within that range. I've left a suggestion to improve the test.
Also, the pull request title mentions adding a Trunc expression, but it doesn't seem to be included in the changes. This might be intentional, but it's worth clarifying.
Note: Security Review did not run due to the size of the PR.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/google-cloud-firestore/tests/system/pipeline_e2e/math.yaml (316-322)
This test is logically flawed because it calls Rand() twice within the And expression. This means two different random numbers will be generated, and the test is checking if rand1 >= 0.0 and rand2 < 1.0. This doesn't correctly verify that a single random number is within the [0.0, 1.0) range.
For example, if the first Rand() returned 2.0 and the second returned 0.5, the expression (2.0 >= 0.0) AND (0.5 < 1.0) would evaluate to true, even though 2.0 is outside the expected range.
A more robust test would use the result of a single Rand() call. Since the PR title mentions Trunc, I assume a Trunc expression is available or will be soon. You could use it to verify the range with a single Rand() call, which would be a much stronger guarantee of correctness.
- FunctionExpression.equal:
- FunctionExpression.trunc:
- Rand: []
- Constant: 0.0PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.0.0-20260216162532-e323d455c92b Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:160860d189ff1c2f7515638478823712fa5b243e27ccc33a2728669fa1e2ed0c <details><summary>django-google-spanner: v4.0.3</summary> ## [v4.0.3](django-google-spanner-v4.0.2...django-google-spanner-v4.0.3) (2026-03-23) ### Bug Fixes * db_returning should only be overridden for Spanner (#16111) ([8c1eb13](8c1eb13f)) </details> <details><summary>google-cloud-dataplex: v2.17.0</summary> ## [v2.17.0](google-cloud-dataplex-v2.16.0...google-cloud-dataplex-v2.17.0) (2026-03-23) ### Features * add support for attaching aspects to EntryLinks (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add DataProductService to manage data products and underlying data assets (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add LookupContext to CatalogService for LLM-generated resource context (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add debug query support to Data Quality rules (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add UpdateEntryLink and LookupEntryLinks methods to CatalogService (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * allow selective generation scope for Data Documentation scans (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * support OneTime triggers for DataScan operations (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add SKIPPED state to DataScan catalog publishing status (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) * add MetadataFeed to CatalogService for tracking metadata changes (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) ### Bug Fixes * remove deprecated Explore-related methods and messages from public client libraries Breaking Changes: - Removed ContentService and all associated methods (CreateContent, UpdateContent, DeleteContent, GetContent, ListContent, etc.) and request/response messages. - Removed Environment and Session management methods from DataplexService (CreateEnvironment, UpdateEnvironment, DeleteEnvironment, ListEnvironments, GetEnvironment, ListSessions) and their associated messages. (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) ### Documentation * remove deprecated metadata change warnings in Dataplex Catalog The DataProductService provides APIs to curate and manage collections of data assets as data products, enabling more organized sharing and usage for specific business cases. MetadataFeeds allow users to monitor metadata changes (CREATE, UPDATE, DELETE) within a specified scope (organization, project, or entry group) and publish them to Pub/Sub. CatalogService now includes a LookupContext API to provide LLM-generated context for resources, and enhanced EntryLink management, including the ability to attach aspects. DataScan operations now support a OneTime trigger for single-run scans, and Data Quality rules support DebugQueries to help investigate rule failures by returning diagnostic values. (PiperOrigin-RevId: 883306841) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>google-cloud-documentai: v3.12.0</summary> ## [v3.12.0](google-cloud-documentai-v3.11.0...google-cloud-documentai-v3.12.0) (2026-03-23) ### Features * Add a field for upgrading previous processor version when fine tuning (PiperOrigin-RevId: 882129422) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>google-cloud-firestore: v2.26.0</summary> ## [v2.26.0](google-cloud-firestore-v2.25.0...google-cloud-firestore-v2.26.0) (2026-03-23) ### Features * Add `Rand` and `Trunc` expressions (#16037) ([7538aa5](7538aa5d)) </details> <details><summary>google-cloud-iap: v1.20.0</summary> ## [v1.20.0](google-cloud-iap-v1.19.0...google-cloud-iap-v1.20.0) (2026-03-23) ### Features * add oauth fields for IapSettings (PiperOrigin-RevId: 883439941) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>google-cloud-network-connectivity: v2.14.0</summary> ## [v2.14.0](google-cloud-network-connectivity-v2.13.0...google-cloud-network-connectivity-v2.14.0) (2026-03-23) ### Features * onboard a new library (PiperOrigin-RevId: 876282040) ([2647414](2647414d)) ### Bug Fixes * add warehouse package name to v1beta (PiperOrigin-RevId: 885295553) ([3701721](37017215)) </details> <details><summary>google-cloud-securitycenter: v1.43.0</summary> ## [v1.43.0](google-cloud-securitycenter-v1.42.0...google-cloud-securitycenter-v1.43.0) (2026-03-23) ### Features * Support Chokepoint and external exposure in findings Proto (PiperOrigin-RevId: 884685891) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>google-cloud-vectorsearch: v0.8.0</summary> ## [v0.8.0](google-cloud-vectorsearch-v0.7.0...google-cloud-vectorsearch-v0.8.0) (2026-03-23) ### Features * Add support for ExportDataObjects (PiperOrigin-RevId: 882214457) ([ee7dd7d](ee7dd7dc)) * Mark Vector Search v1 API as GA (PiperOrigin-RevId: 882214457) ([ee7dd7d](ee7dd7dc)) ### Documentation * Update changelog entry for release (#16092) ([1289664](12896643)) </details> <details><summary>google-maps-navconnect: v0.1.0</summary> ## [v0.1.0](google-maps-navconnect-v0.0.0...google-maps-navconnect-v0.1.0) (2026-03-23) ### Features * onboard a new library (PiperOrigin-RevId: 879267201) ([2158300](21583003)) </details> <details><summary>google-shopping-css: v0.4.0</summary> ## [v0.4.0](google-shopping-css-v0.3.0...google-shopping-css-v0.4.0) (2026-03-23) ### Features * add product rating fields to CSS API v1. This is in preparation for an upcoming feature and the new fields are not yet used. (PiperOrigin-RevId: 882470295) ([ee7dd7d](ee7dd7dc)) ### Documentation * A comment for field `name` in message `.google.shopping.css.v1.GetCssProductRequest` is changed (PiperOrigin-RevId: 882470295) ([ee7dd7d](ee7dd7dc)) * A comment for field `size_types` in message `.google.shopping.css.v1.Attributes` is changed (PiperOrigin-RevId: 882470295) ([ee7dd7d](ee7dd7dc)) * A comment for field `name` in message `.google.shopping.css.v1.CssProductInput` is changed (PiperOrigin-RevId: 882470295) ([ee7dd7d](ee7dd7dc)) * A comment for field `name` in message `.google.shopping.css.v1.AccountLabel` is changed (PiperOrigin-RevId: 882470295) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>google-shopping-merchant-accounts: v1.4.0</summary> ## [v1.4.0](google-shopping-merchant-accounts-v1.3.0...google-shopping-merchant-accounts-v1.4.0) (2026-03-23) ### Features * Add CreateTestAccount RPC to Accounts service for creating test-only Merchant Center accounts (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) ### Documentation * Improve TermsOfServiceKind.MERCHANT_CENTER comment (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Update Region to support radius_area and clarify area type exclusivity (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Update Account.account_name documentation for naming restrictions (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Clarify CheckoutSettings.eligible_destinations usage (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Add product-ratings to Program documentation (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Update DeleteUser method description (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) * Refine DeveloperRegistration.developer_email behavior description (PiperOrigin-RevId: 884882604) ([75697a6](75697a6f)) </details> <details><summary>google-shopping-merchant-products: v1.4.0</summary> ## [v1.4.0](google-shopping-merchant-products-v1.3.0...google-shopping-merchant-products-v1.4.0) (2026-03-23) ### Features * Added several fields to enhance shipping configurations: - `handling_cutoff_time` and `handling_cutoff_timezone` within the `Shipping` message - `ShippingBusinessDaysConfig` message to define business days for shipping - `shipping_handling_business_days` and `shipping_transit_business_days` in `ProductAttributes` - `HandlingCutoffTime` message to configure country-specific handling cutoffs - `handling_cutoff_times` array in `ProductAttributes` (PiperOrigin-RevId: 830818193) ([ee7dd7d](ee7dd7dc)) * Added C#, PHP, and Ruby namespace options to ProductInputs, Products, and ProductsCommon proto files for improved client library generation (PiperOrigin-RevId: 830818171) ([ee7dd7d](ee7dd7dc)) * update products_common fields to include `handling_cutoff_timezone `, `shipping_handling_business_days`, `shipping_transit_business_days` (PiperOrigin-RevId: 881874426) ([ee7dd7d](ee7dd7dc)) * Added `handling_cutoff_time` and `handling_cutoff_timezone` fields to the `Shipping` message within `Attributes` (PiperOrigin-RevId: 830818171) ([ee7dd7d](ee7dd7dc)) * Added the `product_id_base64_url_encoded` field to `InsertProductInputRequest`, `DeleteProductInputRequest`, and `GetProductRequest`. This allows for product IDs containing special characters to be correctly handled when unpadded base64url-encoded (PiperOrigin-RevId: 830818193) ([ee7dd7d](ee7dd7dc)) ### Documentation * Updated various comments, including links to data source creation guides (PiperOrigin-RevId: 830818193) ([ee7dd7d](ee7dd7dc)) * Updated comments for several fields, including product name formats, data source creation, destination field descriptions (now also referred to as Marketing Methods), and the default page size for `ListProductsRequest` (PiperOrigin-RevId: 830818171) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>grafeas: v1.21.0</summary> ## [v1.21.0](grafeas-v1.20.0...grafeas-v1.21.0) (2026-03-23) ### Features * Added line_number to FileLocation (PiperOrigin-RevId: 882149723) ([ee7dd7d](ee7dd7dc)) </details> <details><summary>sqlalchemy-spanner: v1.17.3</summary> ## [v1.17.3](sqlalchemy-spanner-v1.17.2...sqlalchemy-spanner-v1.17.3) (2026-03-23) ### Bug Fixes * provide default sqlite db config for unit tests ([03cce70](03cce701)) * add missing docs and docfx sessions ([8fb857d](8fb857df)) * remove test_config generation from unit session ([9cc1f90](9cc1f90b)) </details>
TODO: