Repository navigation
Support BigQuery load job reservations in Java BigQueryIO - #41329
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR adds support for specifying a BigQuery reservation on FILE_LOADS jobs (BigQueryIO.Write.withLoadJobReservation), propagating the setting through BatchLoads, WriteTables, UpdateSchemaDestination, BigQueryServices, and BigQueryIOTranslation with solid unit test coverage.
🔍 General Feedback
- Runtime
ValueProviderhandling for optional template parameters: WhenwithLoadJobReservation(ValueProvider<String>)is wired in a pipeline template, theValueProviderinstance itself is non-null at construction time, butloadJobReservation.get()will returnnull(or"") at runtime when the optional parameter is not supplied by the user.WriteTablesandUpdateSchemaDestinationshould treat anull/empty runtime value as unset rather than throwingIllegalArgumentException, matching howloadJobProjectIdandcustomGcsTempLocationbehave. - Delegation in
BigQueryServicesImplandFakeJobService: ExistingstartLoadJoboverloads can delegate to the new reservation-aware overloads withnullto eliminate duplicate job construction logic and allowFakeJobServiceto support unreserved stream load jobs as well.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Assigning reviewers: R: @ahmedabu98 for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Add coverage for stream load requests with and without a reservation.
|
Hi @ahmedabu98, when you have a chance, could you please take a look at this PR? The automated review feedback has been addressed, and the targeted tests pass. Thank you! |
|
Hi @Abacn, since @ahmedabu98 might be busy, could you please take a look at this PR when you have a moment? The automated review feedback has been addressed and all targeted tests are passing. Thanks! |
ahmedabu98
left a comment
There was a problem hiding this comment.
The changes so far look good, but I think it's a little incomplete.
We should pass the reservation to the copy-job path as well (should go through WriteRename and BigQueryServices#startCopyJob(...). And add relevant tests please
Thats a good observation. I have made the changes but before committing would like to share the observations
So it looks like adding reservation in the copy job does not has any impact. Even on a dataset with Also I was looking into this documentation - https://docs.cloud.google.com/bigquery/docs/reservations-workload-management#reservation_assignments which does not explicitly mention COPY job. Do you think we still should propagate the |
|
I see, that's rather interesting. Thanks for trying it out. I'll leave it up to you. I'm okay with leaving it out for now, although if BQ decides to add reservation support to copy jobs, we'll have to add it back in the future. Either way I think we should add a small mention in javadoc somewhere about the behavior of reservations on copy jobs |
|
Thanks for the feedback!
I decided to pass the reservation to copy jobs as well. I think it make sense to add this. COPY JOB API also supports this reservation parameter , so it's consistent with the load job. and Indeed if in future BQ changes the behaviour then this is already covered. I’ve also added small note in the Javadoc to mention that the reservation is passed to copy jobs and that BigQuery’s handling may differ from load jobs. |
|
Awesome thank you! merging now |
Adds an optional reservation setting to Java
BigQueryIO.WriteforFILE_LOADS. This allows load jobs to specify a reservation managed in another project instead of relying only on the job project's assignment.The reservation is passed to regular, temporary-table, and schema-update load jobs. It supports
ValueProviderfor runtime configuration.Existing behavior is unchanged when no reservation is specified.
withLoadJobProjectIdcontinues to control the project in which the load job is created; the reservation setting does not change it.Fixes #41212
Validation