Skip to content

feat(bigquery): add internal listProjects API to core client#13429

Merged
keshavdandeva merged 7 commits into
mainfrom
add-listProjects
Jun 17, 2026
Merged

feat(bigquery): add internal listProjects API to core client#13429
keshavdandeva merged 7 commits into
mainfrom
add-listProjects

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/521443900

This PR introduces support for fetching a list of GCP projects via the BigQuery API. This functionality is being exposed primarily to support cross-project dataset resolution in the native BigQuery JDBC driver.

Changes included:

  • Domain Model: Added Project domain model representing a BigQuery project (@BetaApi).
  • Client Interface: Added listProjects(ProjectListOption... options) to the BigQuery client interface, marked as @InternalApi to preserve the public GA surface.
  • SPI Layer: Added listProjects mapping to BigQueryRpc and implemented the underlying HTTP execution in HttpBigQueryRpc, including pagination and OpenTelemetry tracing support.
  • Implementation: Implemented ProjectPageFetcher inside BigQueryImpl to seamlessly handle paginated project results.
  • Testing: Added unit test coverage in BigQueryImplTest and HttpBigQueryRpcTest.

@keshavdandeva keshavdandeva requested review from a team as code owners June 11, 2026 14:40
@keshavdandeva keshavdandeva requested a review from lqiu96 June 11, 2026 14:41

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to list Google Cloud Projects accessible to the caller. It adds a new Project model class, a ProjectListOption class for pagination options, and the listProjects method to the BigQuery interface and its implementation BigQueryImpl. It also updates the underlying RPC layer (BigQueryRpc and HttpBigQueryRpc) to support the new API call with OpenTelemetry tracing, and includes corresponding unit tests. There are no review comments to address.

Comment on lines +33 to +35
this.id = id;
this.numericId = numericId;
this.projectId = projectId;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

qq, what is the difference between id, numericId, and projectId?

From the link (https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/projects/list), I see id and numericId, but not projectId

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the underlying REST API representation of a project (which maps to the client's ProjectList.Projects class):

  • id: The top-level resource ID.
  • numericId: The unique numeric project number (e.g., 123456789012).
  • projectId: Extracted from the nested projectReference.projectId object (e.g., my-project-id), which is what other BigQuery APIs use to reference this project.


/** Class for specifying project list options. */
class ProjectListOption extends Option {
private static final long serialVersionUID = 1L;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this should be too impactful otherwise, but you can have intellij autogenerate a value for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

* @param options options for listing projects
* @return a page of projects
*/
@InternalApi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, I think this is an offical BigQuery api (https://docs.cloud.google.com/bigquery/docs/reference/rest/v2/projects/list) and we probably don't need to add InternalApi here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, okay. Changed it to @BetaApi

@keshavdandeva keshavdandeva requested a review from lqiu96 June 16, 2026 21:57
Comment on lines +354 to +355
Tuple<String, Iterable<ProjectList.Projects>> result =
serviceOptions.getBigQueryRpcV2().listProjects(optionsMap);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

qq, do you need retries for this?

Something similar to

Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>> result =
BigQueryRetryHelper.runWithRetries(
new Callable<
Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>>>() {
@Override
public Tuple<String, Iterable<com.google.api.services.bigquery.model.Dataset>>
call() throws IOException {
return serviceOptions
.getBigQueryRpcV2()
.listDatasetsSkipExceptionTranslation(projectId, optionsMap);
}
},
serviceOptions.getRetrySettings(),
serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
serviceOptions.getOpenTelemetryTracer());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good catch. I'll add it

@lqiu96

lqiu96 commented Jun 17, 2026

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for listing Google BigQuery projects by adding the new Project model, ProjectListOption configuration, and the listProjects API method to the BigQuery service and its RPC implementation. Unit tests have also been added to verify the new functionality. The reviewer suggested improving null safety in the new Project class by annotating the nullable getter methods (getNumericId, getProjectId, and getFriendlyName) with @Nullable.

@keshavdandeva keshavdandeva requested a review from lqiu96 June 17, 2026 16:46
@keshavdandeva keshavdandeva merged commit 3580407 into main Jun 17, 2026
187 of 188 checks passed
@keshavdandeva keshavdandeva deleted the add-listProjects branch June 17, 2026 19:13
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.

3 participants