2
votes

I'm trying to insert a row using this example code:

https://developers.google.com/bigquery/streaming-data-into-bigquery#streaminginsertexamples

TableRow row = new TableRow();
row.set("Col1", 50);
row.set("Col2", 50);
TableDataInsertAllRequest.Rows rows = new TableDataInsertAllRequest.Rows();
rows.setInsertId("" + System.currentTimeMillis());
rows.setJson(row);
List rowList = new ArrayList();
rowList.add(rows);
TableDataInsertAllRequest content = new TableDataInsertAllRequest().setRows(rowList);
try
{
  TableDataInsertAllResponse response =
      bigquery
      .tabledata()
      .insertAll("<myprojectid>", "6bc2cf53x8684x42a4x8149x9ff20fa8beed", "TestTable", content)
      .execute();

  System.out.println("Response: " + response);
}
catch (IOException e)
{
  // handle
}

Schema is this:

Col1 INTEGER NULLABLE
Col2 INTEGER NULLABLE

I'm receiving an error:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 500
{
  "code" : 500,
  "errors" : [ {
    "domain" : "global",
    "message" : "Unexpected. Please try again.",
    "reason" : "internalError"
  } ],
  "message" : "Unexpected. Please try again."
}

Project exists, dataset exists, table exists, data types match the column spec, and I'm using the example code. Jordan said on this question [1] that 500 means a BigQuery bug. I don't mind working around it (if that's it) but I have no idea how to. What can I try? I've hardcoded simple values for each column, I've tried a different table, I've tried a different, brand-new project/dataset/table set. Same result.

This is both on the dev or GAE environment.

If it helps:

Project number: 1066943214796 (note I'm not using that, I'm using the string id in the call), datasetid and table now in the code above.

[1] HTTP error 500 when requesting google big query API using service account

2
Can you paste your code? I copy pasted the sample code, filled in my values, everything is working as expected. I want to check what might be different.Felipe Hoffa

2 Answers

3
votes

I was able to reproduce and identify the problem!

I get the exact same error, unless I rename the dataset. After I changed "6bc2cf53x8684x42a4x8149x9ff20fa8beed" to an existing, simpler string, it all worked.

Can you try a different dataset name? I'll file a bug to discover why this is happening in the meantime.

3
votes

Have you deleted and re-created the tables you have been trying to insert data into?

We (BigQuery team) have been investigating the error and believe it is caused by cache inconsistency issues in the system. The cache can end up in this state if:

1) a table is created 2) some rows are streamed to the table 3) table is deleted and recreated 4) more rows are streamed to the table -- internalError

It would be useful to know if this matches the sequence of operations you were attempting.

The cache itself invalidates itself in ~30min at which point the operations should succeed. We are working on a fix but a temporary work around is to avoid reusing a table name.

When the issue is fixed I will update this question.