question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change in TableId behaviour for non default BigQueryClient project 1.44 -> 1.45

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lepistonecommented, Mar 21, 2019

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

          tableId.setProjectId(
              Strings.isNullOrEmpty(tableId.getProjectId())
                  ? serviceOptions.getProjectId());
                  : tableId.getProject()

Or maybe, the confusion arose between TableId and TableInfo. The code above calls TableId::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#L100

Thanks!

0reactions
polleygcommented, Dec 13, 2018

@chingor13 I was about to ask the same. He’s all the references I see to setProject() in my IDEA… screen shot 2018-12-13 at 11 00 13 am

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found