feat(firestore): add raw execute options and move options #14259
Merged
bhshkh merged 2 commits intogoogleapis:mainfrom Mar 25, 2026
Merged
feat(firestore): add raw execute options and move options #14259bhshkh merged 2 commits intogoogleapis:mainfrom
bhshkh merged 2 commits intogoogleapis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to specify raw execution options for Firestore pipelines using WithRawExecuteOptions, which are then passed directly to the backend. It also refactors the Pipeline.Execute method to accept ExecuteOptions directly, removing the separate WithExecuteOptions method. The Pipeline.copy() method was updated to handle deep copying of these new raw options. An integration test was added to verify the WithRawExecuteOptions functionality. A minor issue was noted regarding leftover debugging code in firestore/pipeline_result.go that prints marshaled requests and ignores potential errors.
daniel-sanche
approved these changes
Mar 25, 2026
hongalex
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Java and node Allow passing raw options to execute but Go does not. This PR adds the change.
removal of WithExecuteOptions:
The removal of
WithExecuteOptionson thePipelinebuilder and the shifting of its arguments directly intoExecute(ctx, opts...)is a design pattern choice rooted heavily in idiomatic Go practices and separation of concerns.Here is a detailed breakdown of exactly why this change was made:
Separation of Definition vs. Execution
A
Pipelinestruct represents an immutable definition of a query. It builds a data structure that describes what data you want (e.g.,Where(...),Select(...),Aggregate(...)).Execution options, on the other hand, describe how you want the backend to process that query (e.g., "return explain metrics", "use a specific index mode", "pass these raw backend flags").
If
WithExecuteOptionswas left on thePipeline, you would be coupling the query's definition with its execution metadata. By movingExecuteOptionto be a variadic argument on theExecute()method itself, you completely separate the two concerns.Reusability of the Pipeline
Because the definition is now separated from the execution telemetry, a developer can build a pipeline once and execute it in multiple different ways without having to clone or mutate it:
If
WithExecuteOptionsexisted, the developer would have to fork the pipeline state to achieve this (myPipeline.WithExecuteOptions(...)).The Idiomatic "Functional Options" Pattern
In Go, it is standard practice for functions that trigger a network request or a concrete action (
Get,Set,Execute) to accept operational modifiers as trailing variadic arguments.If you look at the rest of the Google Cloud SDKs (or even standard library packages like
grpc), you will see this pattern everywhere:client.Collection("c").Doc("d").Get(ctx, firestore.opts...)client.RunTransaction(ctx, f, firestore.opts...)Moving
opts ...ExecuteOptiondirectly intoExecute(ctx context.Context, opts ...ExecuteOption)ensures maximum consistency with the rest of the Go SDK's API surface.