From 237264a6a87cf6f44a1e5a34e595a82d7be0f718 Mon Sep 17 00:00:00 2001 From: rsora Date: Fri, 24 Sep 2021 15:44:15 +0200 Subject: [PATCH] [skip changelog] Add partition load query before fetching metrics and schedule extraction 3 times a day --- .github/tools/fetch_athena_stats.sh | 29 +++++++++++++++++++++++++++- .github/workflows/arduino-stats.yaml | 4 ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/tools/fetch_athena_stats.sh b/.github/tools/fetch_athena_stats.sh index b7010a8235b..e04ca51d38a 100755 --- a/.github/tools/fetch_athena_stats.sh +++ b/.github/tools/fetch_athena_stats.sh @@ -14,6 +14,34 @@ set -euo pipefail +loadExecutionId=$( + aws athena start-query-execution \ + --query-string "MSCK REPAIR TABLE ${AWS_ATHENA_SOURCE_TABLE};" \ + --result-configuration "OutputLocation=${AWS_ATHENA_OUTPUT_LOCATION}" \ + --region us-east-1 | jq -r ".QueryExecutionId" +) + +echo "QueryExecutionId is ${loadExecutionId}" +for i in $(seq 1 120); do + loadState=$( + aws athena get-query-execution \ + --query-execution-id "${loadExecutionId}" \ + --region us-east-1 | jq -r ".QueryExecution.Status.State" + ) + + if [[ "${loadState}" == "SUCCEEDED" ]]; then + break + fi + + echo "QueryExecutionId ${loadExecutionId} - state is ${loadState}" + + if [[ "${loadState}" == "FAILED" ]]; then + exit 1 + fi + + sleep 2 +done + ! read -r -d '' query <