Skip to content

feat(firestore): global option to turn on implicit orderby#2337

Open
wu-hui wants to merge 1 commit intomainfrom
feat-implicit-orderby
Open

feat(firestore): global option to turn on implicit orderby#2337
wu-hui wants to merge 1 commit intomainfrom
feat-implicit-orderby

Conversation

@wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Mar 9, 2026

Introduces a new global option alwaysUseImplicitOrderBy in FirestoreOptions to control whether implicit order bys (e.g. for inequality queries) are sent to the backend. By default, it is false (meaning the SDK only sends explicit order bys). Enterprise users can opt-in to always send them by setting this new option to true to mimic Standard tier behavior.

Related modifications:

  • Added alwaysUseImplicitOrderBy to FirestoreOptions.
  • Query.java handles this serialization flag to send implicit orders for fields with inequalities.
  • Watch.java was updated to always send implicit orders for streaming, regardless of the flag.
  • Added comprehensive unit tests and integration tests.

@wu-hui wu-hui requested a review from a team as a code owner March 9, 2026 20:22
@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 9, 2026
Copy link
Contributor

@MarkDuckworth MarkDuckworth left a comment

Choose a reason for hiding this comment

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

LGTM. The JavaDoc comment on the setting could use a little cleanup for readabiliy, but looks good

/**
* Sets whether to always use implicit order bys (e.g., for inequality queries).
*
* <p>By default, the SDK only sends explicit order bys and relies on the backend to append
Copy link
Contributor

Choose a reason for hiding this comment

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

Unclear if you need the <p> tag

*
* <p>By default, the SDK only sends explicit order bys and relies on the backend to append
* implicit order bys (unless cursors are involved). However, enterprise edition does not
* enforce implicit order bys because it does not back all queries with an index. This option
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to add something like: "In standard edition databases, all queries were backed with an index, so implicit order bys are applied to every query."

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: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants