Basically my code looks like an official example at https://cloud.google.com/bigquery/streaming-data-into-bigquery
My code is:
TableRow data = new TableRow(); data.set("type", eventType); data.set("timestamp", new Date()); TableDataInsertAllRequest.Rows row = new TableDataInsertAllRequest.Rows(); row.setInsertId(System.currentTimeMillis()); row.setJson(data); request = new TableDataInsertAllRequest(); request.setRows(Arrays.asList(row)); TableDataInsertAllResponse response = bigquery.tabledata().insertAll(projectId, datasetId, tableId, request).execute(); for (TableDataInsertAllResponse.InsertErrors err: response.getInsertErrors()) { for (ErrorProto ep: err.getErrors()) { log.error(ep.getReason() + " : " + ep.getMessage() + " at " + ep.getLocation()); } }
But I get the error:
invalid : JSON map specified for non-record field at null
It seems like I missed something, but I have no idea what happened to my code. I have two fields: String and Date , and the error message does not make any sense to me.
How to insert data into a BigQuery table?
source share