Skip to content

Conversation

@nickcaballero
Copy link

@nickcaballero nickcaballero commented Apr 10, 2025

This PR adds support for setting the quota project used when connecting to BigQuery. By default, the project where the dataset lives is used, but some teams use quota projects to separate resources from billing.

@google-cla
Copy link

google-cla bot commented Apr 10, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jayehwhyehentee jayehwhyehentee requested review from jayehwhyehentee and prashastia and removed request for jayehwhyehentee October 27, 2025 05:13
Copy link
Collaborator

@jayehwhyehentee jayehwhyehentee left a comment

Choose a reason for hiding this comment

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

Thank you for raising this PR @nickcaballero. I have left a few minor comments. Can you share results from any actual invocation of this new functionality that demonstrates that it works as expected?

Comment on lines +201 to +203
if (credentials instanceof QuotaProjectIdProvider) {
return ((QuotaProjectIdProvider) credentials).getQuotaProjectId();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed? Credentials are passed to the BQ client, and if they contain quota project, then doesn't the BQ client acknowledge them?

.setCredentialsProvider(
FixedCredentialsProvider.create(options.getCredentials()))
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.setQuotaProjectId(quotaProjectId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

For clarity, please set quotaProjectId only if it is not null

Comment on lines +142 to +143
Credentials credentials = options.getCredentials();
quotaProjectId = BigQueryUtils.getQuotaProjectId(options, credentials);
Copy link
Collaborator

Choose a reason for hiding this comment

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

These variables should only be used once, so no value in storing them. Please revert to in-place retrievals.

Comment on lines +206 to +211
Credentials credentials = options.getCredentials();
String quotaProjectId = BigQueryUtils.getQuotaProjectId(options, credentials);
BigQueryWriteSettings.Builder settingsBuilder =
BigQueryWriteSettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(options.getCredentials()))
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.setQuotaProjectId(quotaProjectId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as previous comments

Comment on lines +332 to +337
Credentials credentials = options.getCredentials();
String quotaProjectId = BigQueryUtils.getQuotaProjectId(options, credentials);
bigQuery =
BigQueryOptions.newBuilder()
.setCredentials(options.getCredentials())
.setCredentials(credentials)
.setQuotaProjectId(quotaProjectId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as previous comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants