-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- API: google-cloud-bigquery
- OS type and version: macOS 10.14.6
- Java version: 1.8.0_221
- google-cloud-java version(s): 1.91.0
More precisely, the only google-related dependency included in my pom.xml is the following:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.91.0</version>
</dependency>
Steps to reproduce
- Include this in your
pom.xml:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.91.0</version>
</dependency>
- Adapt and run this code:
import com.google.auth.Credentials;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Table;
import com.google.cloud.bigquery.TableId;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class Main {
private static final String CREDENTIALS_PATH = "/Users/sergiorodriguez/key.json";
private static final String PROJECT_ID = "streamsets-engineering";
private static final String DATASET_NAME = "sergio_dataset";
// Will throw NullPointerException if empty, and specific error if not empty
private static final String TABLE_NAME = "";
private Credentials getCredentials(String path) throws IOException {
File credentialsFile = new File(path);
return ServiceAccountCredentials.fromStream(new FileInputStream(credentialsFile));
}
private Main() throws IOException {
Credentials credentials = getCredentials(CREDENTIALS_PATH);
BigQueryOptions options = BigQueryOptions.newBuilder()
.setCredentials(credentials)
.setProjectId(PROJECT_ID)
.build();
BigQuery bigQuery = options.getService();
TableId tableId = TableId.of(DATASET_NAME, TABLE_NAME);
Table table = bigQuery.getTable(tableId);
System.out.println(table);
}
public static void main(String[] args) throws IOException {
new Main();
}
}Stack trace
Exception in thread "main" java.lang.NullPointerException
at com.google.cloud.bigquery.TableId.fromPb(TableId.java:108)
at com.google.cloud.bigquery.TableInfo$BuilderImpl.<init>(TableInfo.java:174)
at com.google.cloud.bigquery.Table.fromPb(Table.java:624)
at com.google.cloud.bigquery.BigQueryImpl.getTable(BigQueryImpl.java:677)
at es.sergiorgs.Main.<init>(Main.java:51)
at es.sergiorgs.Main.main(Main.java:56)
Any additional information below
If TABLE_NAME is not empty then it works as expected (i.e: specific, expected responses for invalid table names, returning null when table does not exist and so on).
It feels very similar to #3982 . However, this issue appears as fixed.
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.