0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

指定したdataset配下のTBの有効期限を一括で"none"にするシェル

Last updated at Posted at 2024-06-12
#!/bin/bash

PROJECT_ID=任意のもの
DATASET_ID=任意のもの
NEW_EXPIRATION="none"

TABLES=$(bq ls --project_id=$PROJECT_ID --dataset_id=$DATASET_ID --format=json | jq -r '.[] | .tableReference.tableId')

for TABLE in $TABLES; do
    bq show --format=prettyjson $PROJECT_ID:$DATASET_ID.$TABLE > schema.json
    jq '.expirationTime = "'$NEW_EXPIRATION'"' schema.json > temp.json
    bq update --source=temp.json $PROJECT_ID:$DATASET_ID.$TABLE
    rm schema.json temp.json
done
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?