feat(bigquery): add internal listProjects API to core client#13429
feat(bigquery): add internal listProjects API to core client#13429keshavdandeva wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Shouldn't we use String.equals there?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Can we keep name consistent with API? maxResults?
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
Will it automatically populate maxResults/pageSize?
There was a problem hiding this comment.
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
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:
Projectdomain model representing a BigQuery project (@BetaApi).listProjects(ProjectListOption... options)to theBigQueryclient interface, marked as@InternalApito preserve the public GA surface.listProjectsmapping toBigQueryRpcand implemented the underlying HTTP execution inHttpBigQueryRpc, including pagination and OpenTelemetry tracing support.ProjectPageFetcherinsideBigQueryImplto seamlessly handle paginated project results.BigQueryImplTestandHttpBigQueryRpcTest.