【发布时间】:2016-10-07 22:54:42
【问题描述】:
这是我用来向 bigquery 发送 1 行数据的代码。
假设如下:
- 表架构很好(当我在 ui 中创建具有相同架构和相同 1 行数据的表时有效)
- 包含键值对的映射很好
- 凭证很好
- ProjectId、datasetId 和 tableId 是否正确(在创建 url 时通过逐步检查所有内容)
它总是返回没有错误的响应和以下输出: {"kind":"bigquery#tableDataInsertAllResponse"} // 确认状态:200
我的行的结构可能不正确,但我花了很多时间将其分开。据我了解
列表(TableDataInsertAllRequest.Rows 对象)
TableDataInsertAllRequest.Rows 对象包含一个键“json”,其值为 ->
-
地图(包含所需的 JSON 值)
List<TableDataInsertAllRequest.Rows> rowsList = new ArrayList<>(); TableDataInsertAllRequest.Rows oneRow = new TableDataInsertAllRequest.Rows(); try { Map<String, Object> objectMap = new TreeMap<>(); oneRow.setJson(objectMap); } catch (Exception e){ e.printStackTrace(); } rowsList.add(oneRow); TableDataInsertAllRequest content = new TableDataInsertAllRequest(); content.setKind("bigquery#tableDataInsertAllRequest"); content.setRows(rowsList); Bigquery.Tabledata.InsertAll request = bigqueryService.tabledata().insertAll(projectId, datasetId, tableId, content); TableDataInsertAllResponse response = request.execute();
有什么想法吗?
【问题讨论】:
-
延迟多少?根据文档,预计需要几秒钟:cloud.google.com/bigquery/streaming-data-into-bigquery 流式数据可在第一次流式插入表后的几秒钟内进行实时分析。
标签: google-bigquery