Google BigQuery - 将数据流式传输到 BigQuery
Posted
技术标签:
【中文标题】Google BigQuery - 将数据流式传输到 BigQuery【英文标题】:Google BigQuery - Streaming Data Into BigQuery 【发布时间】: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。 【参考方案1】:根据有关数据可用性的文档,看起来当流式传输到分区表时,流式缓冲区中的数据具有 _PARTITIONTIME 伪列的 NULL 值。我还可以看到我们有一些字段,我们可以通过这些字段检查 streamingBuffer.oldestEntryTime 等,
对于我们正在进行流式插入的表,它还提到数据最多可能需要 90 分钟才能用于复制操作。
https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataavailability
【讨论】:
以上是关于Google BigQuery - 将数据流式传输到 BigQuery的主要内容,如果未能解决你的问题,请参考以下文章
将数据从 Google 表格流式传输到 BigQuery 以在 Tableau 中进行可视化
将数据流从 Google Cloud Storage 流式传输到 Big Query
如何使用Appengine和来自API的Python脚本流数据将数据流式传输到Google Cloud BigQuery?
如果我在流式传输之前先删除表并创建表,Google BigQuery Streaming 有时会失败
将 BigQuery 表流式传输到 Google Pub/Sub
GoogleApiException:流式传输到 BigQuery 时,Google.Apis.Requests.RequestError 后端错误 [500]