Skip to content

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

Open
keshavdandeva wants to merge 3 commits into
mainfrom
add-listProjects
Open

feat(bigquery): add internal listProjects API to core client#13429
keshavdandeva wants to merge 3 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.

if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Project project = (Project) o;
return Objects.equals(id, project.id)

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.

Shouldn't we use String.equals there?

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.

Since some of these fields (like friendlyName or projectId) can be null in the API response, calling id.equals(project.id) directly could throw a NPE

super(option, value);
}

public static ProjectListOption pageSize(long pageSize) {

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.

Can we keep name consistent with API? maxResults?

@keshavdandeva keshavdandeva Jun 12, 2026

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.

To maintain consistency with the rest of the API, I usedpageSize(). Throughout BigQuery.java, all paginated APIs (like DatasetListOption, TableListOption, and JobListOption) use pageSize()


ProjectPageFetcher(
BigQueryOptions serviceOptions, String cursor, Map<BigQueryRpc.Option, ?> optionMap) {
this.requestOptions =

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.

Will it automatically populate maxResults/pageSize?

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, The PageImpl.nextRequestOptions(...) utility method takes the original optionMap (which contains MAX_RESULTS and any other options from the initial request) and returns a new map that preserves all of those original options, while simply updating the PAGE_TOKEN key with the new cursor

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