【问题标题】:Scio saveAsTypedBigQuery write to a partition for SCollection of Typed Big Query case classScio saveAs Type BigQuery 写入分区以收集 Typed Big Query 案例类
【发布时间】:2018-06-18 02:02:02
【问题描述】:

我正在尝试使用以下方法将 SCollection 写入 Big Query 中的分区:

import java.time.LocalDate
import java.time.format.DateTimeFormatter
val date = LocateDate.parse("2017-06-21")
val col = sCollection.typedBigQuery[Blah](query)

col.saveAsTypedBigQuery(
      tableSpec = "test.test$" + date.format(DateTimeFormatter.ISO_LOCAL_DATE),
      writeDisposition = WriteDisposition.WRITE_EMPTY,
      createDisposition = CreateDisposition.CREATE_IF_NEEDED)

我得到的错误是 表 ID 必须是字母数字(加上下划线)并且长度不得超过 1024 个字符。另外,不能使用表格装饰器。”

如何写入分区?我没有看到任何通过 saveAsTypedBigQuery 方法指定分区的选项,所以我尝试使用 Legacy SQL 表装饰器。

【问题讨论】:

    标签: google-bigquery google-cloud-dataflow apache-beam apache-beam-io spotify-scio


    【解决方案1】:

    请参阅:BigqueryIO Unable to Write to Date-Partitioned Table。您需要手动创建表。 BQ IO 无法创建表并对其进行分区。

    此外,无表装饰器是一个完整的诡计。这是我缺少的字母数字部分。

    col.saveAsTypedBigQuery(
          tableSpec = "test.test$" + date.format(DateTimeFormatter.BASIC_ISO_DATE),
          writeDisposition = WriteDisposition.WRITE_APPEND,
          createDisposition = CreateDisposition.CREATE_NEVER)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-08
      • 2023-03-03
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多