【问题标题】:Google BigQuery - Streaming Data Into BigQueryGoogle BigQuery - 将数据流式传输到 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。

标签: java google-cloud-platform google-bigquery


【解决方案1】:

根据有关数据可用性的文档,看起来当流式传输到分区表时,流式缓冲区中的数据具有 _PARTITIONTIME 伪列的 NULL 值。我还可以看到我们有一些字段,我们可以通过这些字段检查 streamingBuffer.oldestEntryTime 等,

对于我们正在进行流式插入的表,它还提到数据最多可能需要 90 分钟才能用于复制操作。

https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataavailability

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 2018-10-13
    • 2020-09-03
    • 2017-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多