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 <