如何从 BigQuery 导出到 Datastore?
How to export from BigQuery to Datastore?
我想在 Datastore 中导出和导入 BigQuery 中的表。
如何实现?
您可以将 BigQuery 数据导出为 CSV,然后将 CSV 导入 Datastore。第一步很简单并且有据可查 https://cloud.google.com/bigquery/docs/exporting-data#exporting_data_stored_in_bigquery。对于第二步,有许多资源可以帮助您实现这一目标。例如,
https://groups.google.com/forum/#!topic/google-appengine/L64wByP7GAY
Table 可以将 BigQuery 导出并导入到您的数据存储区。
从 https://github.com/yu-iskw/bigquery-to-datastore/releases
下载 jar 文件
然后运行命令
java -cp bigquery-to-datastore-bundled-0.5.1.jar com.github.yuiskw.beam.BigQuery2Datastore --project=yourprojectId --runner=DataflowRunner --inputBigQueryDataset=datastore --inputBigQueryTable=metainfo_internal_2 --outputDatastoreNamespace=default --outputDatastoreKind=meta_internal --keyColumn=key --indexedColumns=column1,column2 --tempLocation=gs://gsheetbackup_live/temp --gcpTempLocation=gs://gsheetlogfile_live/temp
--tempLocation
和 --gcpTempLocation
是有效的云存储桶 URL。
--keyColumn=key
- 这里的关键是你的大查询中的唯一字段 table
2020年答案,
使用 GoogleCloudPlatform/DataflowTemplates
、BigQueryToDatastore
# Builds the Java project and uploads an artifact to GCS
mvn compile exec:java \
-Dexec.mainClass=com.google.cloud.teleport.templates.BigQueryToDatastore \
-Dexec.cleanupDaemonThreads=false \
-Dexec.args=" \
--project=<project-id> \
--region=<region-name> \
--stagingLocation=gs://<bucket-name>/staging \
--tempLocation=gs://<bucket-name>/temp \
--templateLocation=gs://<bucket-name>/templates/<template-name>.json \
--runner=DataflowRunner"
# Uses the GCS artifact to run the transfer job
gcloud dataflow jobs run <job-name> \
--gcs-location=<template-location> \
--zone=<zone> \
--parameters "\
readQuery=SELECT * FROM <dataset>.<table>,readIdColumn=<id>,\
invalidOutputPath=gs://your-bucket/path/to/error.txt,\
datastoreWriteProjectId=<project-id>,\
datastoreWriteNamespace=<namespace>,\
datastoreWriteEntityKind=<kind>,\
errorWritePath=gs://your-bucket/path/to/errors.txt"
我希望今天能在 GCP Console 中获得正确的用户界面! (因为这对于 Pub/Sub 使用 Dataflow SQL 到 BigQuery 已经成为可能)
我想在 Datastore 中导出和导入 BigQuery 中的表。 如何实现?
您可以将 BigQuery 数据导出为 CSV,然后将 CSV 导入 Datastore。第一步很简单并且有据可查 https://cloud.google.com/bigquery/docs/exporting-data#exporting_data_stored_in_bigquery。对于第二步,有许多资源可以帮助您实现这一目标。例如,
https://groups.google.com/forum/#!topic/google-appengine/L64wByP7GAY
Table 可以将 BigQuery 导出并导入到您的数据存储区。
从 https://github.com/yu-iskw/bigquery-to-datastore/releases
下载 jar 文件然后运行命令
java -cp bigquery-to-datastore-bundled-0.5.1.jar com.github.yuiskw.beam.BigQuery2Datastore --project=yourprojectId --runner=DataflowRunner --inputBigQueryDataset=datastore --inputBigQueryTable=metainfo_internal_2 --outputDatastoreNamespace=default --outputDatastoreKind=meta_internal --keyColumn=key --indexedColumns=column1,column2 --tempLocation=gs://gsheetbackup_live/temp --gcpTempLocation=gs://gsheetlogfile_live/temp
--tempLocation
和 --gcpTempLocation
是有效的云存储桶 URL。
--keyColumn=key
- 这里的关键是你的大查询中的唯一字段 table
2020年答案,
使用 GoogleCloudPlatform/DataflowTemplates
、BigQueryToDatastore
# Builds the Java project and uploads an artifact to GCS
mvn compile exec:java \
-Dexec.mainClass=com.google.cloud.teleport.templates.BigQueryToDatastore \
-Dexec.cleanupDaemonThreads=false \
-Dexec.args=" \
--project=<project-id> \
--region=<region-name> \
--stagingLocation=gs://<bucket-name>/staging \
--tempLocation=gs://<bucket-name>/temp \
--templateLocation=gs://<bucket-name>/templates/<template-name>.json \
--runner=DataflowRunner"
# Uses the GCS artifact to run the transfer job
gcloud dataflow jobs run <job-name> \
--gcs-location=<template-location> \
--zone=<zone> \
--parameters "\
readQuery=SELECT * FROM <dataset>.<table>,readIdColumn=<id>,\
invalidOutputPath=gs://your-bucket/path/to/error.txt,\
datastoreWriteProjectId=<project-id>,\
datastoreWriteNamespace=<namespace>,\
datastoreWriteEntityKind=<kind>,\
errorWritePath=gs://your-bucket/path/to/errors.txt"
我希望今天能在 GCP Console 中获得正确的用户界面! (因为这对于 Pub/Sub 使用 Dataflow SQL 到 BigQuery 已经成为可能)