如何将数据从 Google BigQuery 加载到 Google Cloud Bigtable

How to load data into Google Cloud Bigtable from Google BigQuery

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

作为练习,我可以read the data from BigQuery and as an seperate exercise I am able to write data into Bigtable as well

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

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

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");

以后想把bigquery数据转成bigtable的可以参考下面link

参考:https://github.com/GoogleCloudPlatform/cloud-bigtable-examples/blob/master/java/dataflow-connector-examples/src/main/java/com/google/cloud/bigtable/dataflow/example/BigQueryBigtableTransfer.java