2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

bq commandのscheduled query操作メモ

Posted at

ただのメモです。

scheduled query一覧表示

$ bq ls --transfer_config --transfer_location=us
                                           name                                                              displayName                      dataSourceId       state
 ----------------------------------------------------------------------------------------- ------------------------------------------------ ----------------- -----------
  projects/000000000000/locations/us/transferConfigs/00000000-0000-0000-0000-000000000000   my_scheduled_query                               scheduled_query   SUCCEEDED

scheduled queryの設定表示

$ bq show --format=prettyjson --transfer_config "projects/000000000000/locations/us/transferConfigs/00000000-0000-0000-0000-000000000000"
{
  "dataSourceId": "scheduled_query",
  "datasetRegion": "us",
  "destinationDatasetId": "samples",
  "displayName": "my_scheduled_query",
  "emailPreferences": {
    "enableFailureEmail": true
  },
  "name": "projects/000000000000/locations/us/transferConfigs/00000000-0000-0000-0000-000000000000",
  "params": {
    "destination_table_name_template": "sample2",
    "query": "SELECT * FROM samples.sample LIMIT 1",
    "write_disposition": "WRITE_APPEND"
  },
  "scheduleOptions": {
    "disableAutoScheduling": true
  },
  "state": "FAILED",
  "updateTime": "2020-01-01T00:00:00.000000Z",
  "userId": "xxxxxxxxxxxxxxxxxxx"
}

OnDemandQueryを実行する

$ bq mk \
  --transfer_run \
  --run_time="2020-01-01T00:00:00+09:00" \
  projects/000000000000/locations/us/transferConfigs/00000000-0000-0000-0000-000000000000

scheduled queryを更新する

$ cat << __JSON__ > /tmp/param.json
{
  "query": "SELECT * FROM samples.sample LIMIT 2",
  "destination_table_name_template": "sample2",
  "write_disposition": "WRITE_APPEND"
}
__JSON__

$ bq update \
  --transfer_config \
  --params="$(cat /tmp/param.json)" \
  projects/000000000000/locations/us/transferConfigs/00000000-0000-0000-0000-000000000000
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?