Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45
See original GitHub issueWhen using the getTable method of the BigQuery client the project of the TableId is overwritten. TableId would previously ignore this if a project had been set. Table Id has been changed such that the project is always overwritten. There is now no way to get a table for a project other than the one the client was created for.
TableId tableId = TableId.of(project, schema, tableName);
Table table = client.getTable(tableId);
// table returns null if project != client.getOptions().getProjectId()
this is due to the change in TableId
In BigQueryImpl:
public Table getTable(TableId tableId, TableOption... options) {
final TableId completeTableId = tableId.setProjectId(getOptions().getProjectId());
...
TableId old code:
TableId setProjectId(String projectId) {
return getProject() != null ? this : TableId.of(projectId, getDataset(), getTable());
}
TableId new code:
TableId setProjectId(String projectId) {
Preconditions
.checkArgument(!Strings.isNullOrEmpty(projectId), "Provided projectId is null or empty");
return TableId.of(projectId, getDataset(), getTable());
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (1 by maintainers)
Top Results From Across the Web
Manage tables | BigQuery - Google Cloud
Shows how to manage tables in BigQuery--how to rename, copy, and delete them; update their properties; and restore deleted tables.
Read more >ExtractJobConfiguration's setProjectId makes cross-project BQ ...
I experienced something similar when creating a table in BigQuery, where projectId seems to be re-set with the projectId from BigQueryOptions.
Read more >connecting bigquery to an unintended project - python
I assume you have something like bq = bigquery.Client(project='my-project-id') with proper quotes etc... and yes you should use project id, (not ...
Read more >tabledata() - Google Developers
Streams data into BigQuery one record at a time without needing to run a load job. ... Args: projectId: string, Project ID of...
Read more >Google BigQuery I/O connector - Apache Beam
Table ID : A BigQuery table ID, which is unique within a given dataset. ... If you omit the project ID, Beam uses...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, we believe this is still broken as of today (1.65.0). As in the description of this ticket, still
There is now no way to get a table for a project other than the one the client was created for
.Specifically, in https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java#L635-L639 , the project in my
tableId
will always be overridden with the project of the service, if the service has a project.Maybe the intention of that code was to override the project only if it is not set in tableId? Then the code would look like
Or maybe, the confusion arose between
TableId
andTableInfo
. The code above callsTableId::setProject
, which will always perform the change. See: https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableId.java#L100Thanks!
@chingor13 I was about to ask the same. He’s all the references I see to
setProject()
in my IDEA…