首页 > 解决方案 > 如何使用 BigQuery 命令行工具执行一次性 S3 数据传输?

问题描述

如果您使用控制台,从S3 到 BigQuery的传输可以正常工作。在命令行上,我也可以正常工作,只是有一个参数我找不到如何配置。

在控制台 UI 上,您有“计划选项”,您可以将重复设置为“按需”: 在此处输入图像描述

但是在命令行上我找不到将传输设置为“按需”的方法。你知道我需要传递哪个参数来按需设置它吗?它会自动设置每 24 小时的时间表。

示例运行:

bq mk --transfer_config \
--target_dataset=my_dataset \
--display_name="my_transfer" \
--params='{"data_path":"s3://my_bucket/my_path*",
"destination_table_name_template":"testing",
"file_format":"CSV",
"max_bad_records":"1",
"ignore_unknown_values":"true",
"field_delimiter":";",
"skip_leading_rows":"0",
"allow_quoted_newlines":"false",
"allow_jagged_rows":"false",
"access_key_id": "",
"secret_access_key": ""}' \
--data_source=amazon_s3
#how can I setup the schedule options as on demand?

标签: google-bigquery

解决方案


您需要disableAutoScheduling在 DTS API 中将该参数设置为 false。

https://cloud.google.com/bigquery-transfer/docs/reference/datatransfer/rest/v1/projects.locations.transferConfigs#TransferConfig.ScheduleOptions

例如:

{
   "dataSourceId":"google_cloud_storage",
   "displayName":"bar",
   "params":{
      "destination_table_name_template":"bart",
      "data_path_template":"gs://fuzzy-wuzzy/wiki_1M.csv",
      "write_disposition":"APPEND",
      "file_format":"CSV",
      "max_bad_records":"0",
      "field_delimiter":",",
      "skip_leading_rows":"0"
   },
   "emailPreferences":{
      "enableFailureEmail":false
   },
   "notificationPubsubTopic":null,
   "destinationDatasetId":"another_test",
   "schedule":"",
   "scheduleOptions":{
      "disableAutoScheduling":true
   }
}

要通过 BigQuery CLI 工具执行此操作,您需要使用该no_auto_scheduling标志。

在此处输入图像描述


推荐阅读