Created
June 21, 2018 12:14
-
-
Save markrittman/17a1b2ad994f7fcc8d0fbe855392fe63 to your computer and use it in GitHub Desktop.
Script to patch (rebuild using definition in Github) a business view for a client tracking ID
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
if [ "$#" -ne 4 ] | |
then | |
echo "Usage: ./patchbv client_id tracking_id view_name nested_flatted_flag i.e. patchbv 37028 dnata_travel experience false" | |
exit 1 | |
fi | |
echo "patching qubit-client-$1 $2 $3" | |
gcloud auth login mark.rittman@qubit.com | |
gcloud config set project qubit-client-"$1" | |
echo "deleting existing objects for $2" | |
bq rm -f -t qubit-client-"$1":qubit_bi_"$2".qp_bi_"$3"_all_time_up_to_yesterday | |
bq rm -f -t qubit-client-"$1":qubit_bi_"$2".qp_bi_"$3"_yesterday | |
bq rm -f -t qubit-client-"$1":"$2".qp_bi_"$3" | |
echo "rebuilding $3 history table for $2 with flattened output $4" | |
bq query --allow_large_results --flatten="${4}" --destination_table qubit_bi_"${2}".qp_bi_"$3"_all_time_up_to_yesterday "`curl -X GET --header 'Accept: text/plain' "https://livetap.qutics.com/business_view_sql/"${2}"/qp_bi_"$3"/all_time_up_to_yesterday"`" | |
echo "recreating views for $2" | |
bq mk --view "`curl -X GET --header 'Accept: text/plain' "https://livetap.qutics.com/business_view_sql/"${2}"/qp_bi_"$3"/yesterday"`" qubit_bi_"$2".qp_bi_"$3"_yesterday | |
bq mk --view "`curl -X GET --header 'Accept: text/plain' "https://livetap.qutics.com/business_view_sql/"$2"/qp_bi_"$3"/final"`" "$2".qp_bi_"$3" | |
echo "patching $3 complete for $2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment