【问题标题】:How to load data into Google Cloud Bigtable from Google BigQuery如何从 Google BigQuery 将数据加载到 Google Cloud Bigtable
【发布时间】:2016-12-26 22:15:47
【问题描述】:

我需要将数据填充到 Google Cloud Bigtable 中,数据源将是 Google BigQuery。

作为练习,我可以read the data from BigQuery,作为单独的练习,我可以write data into Bigtable as well

现在我必须将这 2 个操作合并到一个 Google Cloud Dataflow 作业中。任何示例都会有很大帮助。

【问题讨论】:

    标签: google-bigquery google-cloud-dataflow google-cloud-bigtable


    【解决方案1】:

    您可以只使用这些示例中所示的转换,在其间添加您需要的任何逻辑,例如:

    Pipeline p = Pipeline.create(options);
     .apply(BigQueryIO.Read.from("some_table"))
     .apply(ParDo.of(new DoFn<TableRow, Row>() {
       public void processElement(ProcessContext c) {
         Row output = somehowConvertYourDataToARow(c.element());
         c.output(output);
       }
       })
     .apply(BigtableIO.Write.withTableId("some_other_table");
    

    【讨论】:

    • 我尝试执行以下代码 CloudBigtableIO.initializeForWrite(p); p.apply(BigQueryIO.Read.fromQuery(getQuery())) .apply(ParDo.of(new DoFn<tablerow mutation>() { public void processElement(ProcessContext c) { Mutation output = convertDataToRow(c.element() ); c.output(output); } })) .apply(CloudBigtableIO.writeToTable(config)); </tablerow>
    • 但是我得到了以下异常 java.lang.IllegalArgumentException: Unable to encode element 'null' with coder 'HBaseMutationCoder'。
    • 看起来您的代码中某处正在生成空值,Bigtable 编写器不接受。尝试记录突变以查看它或其组成部分是否为空,并确保您的 convertDataToRow 函数不能产生空值
    • 当我使用包含记录类型列(展平)的数据流作业执行 BigQuery 查询时,作为单独的事情,TableRow 对象不会返回记录类型列,但会返回其他列。不知道是什么原因
    • 您能否将其作为一个单独的问题提出,并提供有关您的查询和获得的结果的更多信息?
    【解决方案2】:

    【讨论】:

    • 你能举一个使用一些样本数据的例子吗?例如,someID 作为行键,name,age 作为值?示例 - 1, john doe, 30
    猜你喜欢
    • 2018-04-30
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 2019-08-05
    • 1970-01-01
    相关资源
    最近更新 更多