【发布时间】:2021-03-23 17:01:41
【问题描述】:
我正在为我的项目使用 Google BigQuery 现在我正在尝试基于此 https://cloud.google.com/bigquery/streaming-data-into-bigquery#bigquery-stream-data-java 向 BQ 插入新行
private void insertRowsToBQ(MyCustomObject data) {
String datasetName = "mydatasetname";
String tableName = "mytablename";
Map<String, Object> rowContent = new HashMap<>();
rowContent.put("field_1", data.getdata1());
rowContent.put("field_2", data.getdata2());
rowContent.put("field_3", data.getdata3());
rowContent.put("field_4", data.getdata4());
try {
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
TableId tableId = TableId.of(datasetName, tableName);
InsertAllResponse response =
bigquery.insertAll(
InsertAllRequest.newBuilder(tableId)
.addRow(rowContent)
.build());
if (response.hasErrors()) {
for (Map.Entry<Long, List<BigQueryError>> entry : response.getInsertErrors().entrySet()) {
Logger.error("Response error: \n" + entry.getValue());
}
}
Logger.info("Rows successfully inserted into table");
} catch (BigQueryException e) {
Logger.error("Insert operation not performed \n" + e.toString());
}
}
代码运行正常,没有错误日志 但是当我试图在谷歌控制台上查看它时 https://console.cloud.google.com/bigquery?project=myprojectname
select * from `myprojectname.mydatasetname.mytablename` where DATE(_PARTITIONTIME) = "2021-03-24"
google BQ 控制台上的数据,数据不显示。 结果数据延迟了1个多小时,直到可以在BQ上查看
这是预期的吗?还是有什么问题?
我一直在尝试重新创建数据集和表,但仍然没有成功
【问题讨论】:
-
当您单击表格的预览按钮时,您不应查看数据。但是如果你执行一个查询,没有任何分区值,你应该对你的数据进行 vue。
标签: java google-cloud-platform google-bigquery