You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Java, bigquery-emulator and testcontainers to write integration tests for my app. Thing is, when I am providing my own JobId (even empty one) when creating QueryJobConfiguration, emulator seems to build incorrect (not existing) table name and returns error.
This one bigQuery.query(queryConfig) works, but this one bigQuery.query(queryConfig, jobId) triggers errors. More details below.
What did you expect to happen?
Fact of providing (or not) jobId shouldn't affect the way query is processed
How can we reproduce it (as minimally and precisely as possible)?
Below is a minimal code I'm using to reproduce this error. First query prints 2 as expected. Second one throws com.google.cloud.bigquery.BigQueryException: failed to query select * from tableA: no such table: test-project_tableA.
I can only guess that after adding jobId, table name is missing dataset name?
var bigQueryContainer = new BigQueryEmulatorContainer(
DockerImageName.parse("ghcr.io/goccy/bigquery-emulator:latest")
);
bigQueryContainer.start();
var bigQuery = BigQueryOptions.newBuilder()
.setCredentials(NoCredentials.getInstance())
.setProjectId(bigQueryContainer.getProjectId())
.setHost(bigQueryContainer.getEmulatorHttpEndpoint()).build().getService();
DatasetInfo datasetInfo = DatasetInfo.newBuilder("datasetA").build();
bigQuery.create(datasetInfo);
TableId tableId = TableId.of("datasetA", "tableA");
Schema schema = Schema.of(Field.of("name", StandardSQLTypeName.STRING));
TableDefinition tableDefinition = StandardTableDefinition.of(schema);
TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();
bigQuery.create(tableInfo);
var row1 = InsertAllRequest.RowToInsert.of(Map.of("name", "AAA"));
var row2 = InsertAllRequest.RowToInsert.of(Map.of("name", "BBB"));
InsertAllRequest insertRequest = InsertAllRequest.newBuilder(tableId)
.addRow(row1).addRow(row2).build();
bigQuery.insertAll(insertRequest);
var query = "select * from tableA";
// Works
var queryConfig1 = QueryJobConfiguration.newBuilder(query).setDefaultDataset("datasetA").build();
var result1 = bigQuery.query(queryConfig1);
System.out.println(result1.getTotalRows());
// Doesn't work
var queryConfig2 = QueryJobConfiguration.newBuilder(query).setDefaultDataset("datasetA").build();
var jobId = JobId.newBuilder().build();
var result2 = bigQuery.query(queryConfig2, jobId); // this line throws
System.out.println(result2.getTotalRows());
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered:
What happened?
I'm using Java, bigquery-emulator and testcontainers to write integration tests for my app. Thing is, when I am providing my own JobId (even empty one) when creating QueryJobConfiguration, emulator seems to build incorrect (not existing) table name and returns error.
This one
bigQuery.query(queryConfig)
works, but this onebigQuery.query(queryConfig, jobId)
triggers errors. More details below.What did you expect to happen?
Fact of providing (or not) jobId shouldn't affect the way query is processed
How can we reproduce it (as minimally and precisely as possible)?
Below is a minimal code I'm using to reproduce this error. First query prints
2
as expected. Second one throwscom.google.cloud.bigquery.BigQueryException: failed to query select * from tableA: no such table: test-project_tableA
.I can only guess that after adding jobId, table name is missing dataset name?
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: