【发布时间】:2021-09-20 08:55:54
【问题描述】:
有一个管道可以将表数据从 BigQuery 复制到 CloudSql。
Cloud SQL 表创建发生在数据流之外。
现在我们需要在 Dataflow 中创建表。
我有要在 GCS 存储桶中创建为 .sql 文件的表。
下面是sn-p的代码,将表从BQ复制到sql。
p.apply(BigQueryIO.readTableRows()
.from(source_table)
.withTemplateCompatibility()
.withoutValidation())
.apply(JdbcIO.<TableRow>write()
.withDataSourceConfiguration(
JdbcIO.DataSourceConfiguration.create(
"org.postgresql.Driver",
base_url
)
)
.withStatement("INSERT INTO " + target_table.split("\\.")[1] + " VALUES " + insert_query)
.withPreparedStatementSetter(new StatementSetter(some_map)));
p.run();
有没有办法可以使用 JDBCIO 执行 .sql 文件?
【问题讨论】:
标签: java google-cloud-dataflow apache-beam google-cloud-sql