Last active
December 21, 2015 04:18
-
-
Save palladius/6247967 to your computer and use it in GitHub Desktop.
I drafted the code in here
This file contains hidden or 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 | |
# Case #03352234 | |
# BQ load | |
# Riccardo modifications: | |
# 1. I added a sort/uniq to make sure the lines are unique. | |
# 2. I removed parallelism in bq commands. | |
#composed_files_gs_path='/path/to/gs/files' | |
#total_files=1000 | |
#bqtable='nameoftable' | |
counter=0 | |
gsutil ls $composed_files_gs_path > load.txt | |
cat load.txt |sort|uniq| while read line ; do | |
echo "Loading file " $line "(" $current_file "out of "$total_files")" | |
if [ $counter -eq 5 ]; then | |
sleep 30 | |
/usr/local/bin/bq load --nosync --max_bad_records=10000 --field_delimiter="\t" $bqtable $line | |
counter=1 | |
else | |
/usr/local/bin/bq load --nosync --max_bad_records=10000 --field_delimiter="\t" $bqtable $line | |
let counter=counter+1 | |
fi | |
let current_file=current_file+1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment