Created
May 8, 2020 19:51
-
-
Save yaasita/c40c605e4fe9dc3ac8402d135c1f90c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
function recreate { | |
cat <<EOF > /tmp/query.sql | |
#standardSQL | |
SELECT CAST(id as STRING) as id, description FROM test.first WHERE DATE(_PARTITIONTIME) = "$1"; | |
EOF | |
export partition=$(echo $1 | perl -ple 's/-//g') | |
cat /tmp/query.sql | | |
bq query --append_table --schema_update_option=ALLOW_FIELD_ADDITION \ | |
--destination_table "test.third\$$partition" \ | |
--time_partitioning_type DAY | |
} | |
recreate 2020-05-01 | |
recreate 2020-05-02 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment