Any feature in BigQuery that can migrate a whole dataset in another project w/o executing copy data?

前端 未结 4 1560
无人及你
无人及你 2021-02-08 16:04

While our project grows, at some point we realized that we need to create new projects and reorganize our dataset. One case is that we need to isolate one dataset from others in

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 16:29

    A short shell script which copies all tables from a dataset to another dataset:

    export SOURCE_DATASET=$1  # project1:dataset
    export DEST_PREFIX=$2  # project2:dataset2.any_prefix_
    for f in `bq ls $SOURCE_DATASET |grep TABLE | awk '{print $1}'`
    do
      export CP_COMMAND="bq cp $SOURCE_DATASET.$f $DEST_PREFIX$f"
      echo $CP_COMMAND
      echo `$CP_COMMAND`
    done
    

提交回复
热议问题