Jean-Philippe Caruana
Jean-Philippe Caruana

Reputation: 2706

Stream insert from java: templateSuffix

I would like to stream data from my java code to a BigQuery table using templateSuffix, but I can't make it work properly. My code:

return bigquery.tabledata()
        .insertAll(
                projectId,
                datasetId,
                tableId,
                new TableDataInsertAllRequest()
                        .setTemplateSuffix(templateSuffix)
                        .setRows(singletonList(row))
        ).execute();

When I run it with projectId, datasetId, MyTable20160426 and 20160426, I get the error:

"message" : "404 Not found: Table projectId:datasetId.MyTable20160426"

When I run it with projectId, datasetId, MyTable and 20160426, I get the error:

"message" : "404 Not found: Table projectId:datasetId.MyTable"

The table MyTable already exists and already is templated on date (I used the bulk upload for GCS) (20160426 is the today date)

How cat I make it work ?

Where should I look to understand what's wrong ?

Thanks

Upvotes: 1

Views: 136

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26637

First, the base table projectId:datasetId.MyTable should exist and should already have a schema. Thisis how BigQuery knows how to find the schema of the templated table that gets created.

Second, You should pass MyTable and instead of MyTable20160426 as the table ID in your request.

Third, the existence (or non-existence) of a table is cached. So if you get a "not found" error and then create the table, you'll still get a "not found" error for up to a half hour.

It sounds like you might be able to wait and try again. If this doesn't work, please provide the actual project, dataset, and table ids you're using and e-mail the details to [email protected], and I can help look into what is going on.

Upvotes: 1

Related Questions