Skip to content

Instantly share code, notes, and snippets.

@wutali
Last active December 22, 2015 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wutali/6534208 to your computer and use it in GitHub Desktop.
Save wutali/6534208 to your computer and use it in GitHub Desktop.
Rename dataset on BigQuery.
#!/bin/bash
BQ_CMD='bq'
$BQ_CMD show $1
if [ $? -ne 0 ]; then
echo "ERROR: $1 dataset not found."
exit 1
fi
$BQ_CMD show $2
if [ $? -ne 0 ]; then
$BQ_CMD mk $2
fi
for table in `$BQ_CMD ls -n 1000 $1|sed '1,2d'`; do
$BQ_CMD cp $1.$table $2.$table
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment