boolean shouldRetry(GetQueryExecutionResponse getQueryExecutionResponse) {
        String stateChangeReason = getQueryExecutionResponse.queryExecution().status().stateChangeReason();

        if (this.retry.contains("never")) {
            LOG.trace("AWS Athena start query execution detected error ({}), marked as not retryable",
                    stateChangeReason);
            return false;
        }

        if (this.retry.contains("always")) {
            LOG.trace("AWS Athena start query execution detected error ({}), marked as retryable", stateChangeReason);
            return true;
        }

        // Generic errors happen sometimes in Athena.  It's possible that a retry will fix the problem.
        if (stateChangeReason != null && stateChangeReason.contains("GENERIC_INTERNAL_ERROR")
                && (this.retry.contains("generic") || this.retry.contains("retryable"))) {
            LOG.trace("AWS Athena start query execution detected generic error ({}), marked as retryable",
                    stateChangeReason);
            return true;
        }

        // Resource exhaustion happens sometimes in Athena.  It's possible that a retry will fix the problem.
        if (stateChangeReason != null && stateChangeReason.contains("exhausted resources at this scale factor")
                && (this.retry.contains("exhausted") || this.retry.contains("retryable"))) {
            LOG.trace("AWS Athena start query execution detected resource exhaustion error ({}), marked as retryable",
                    stateChangeReason);
            return true;
        }

        return false;
    }
@Test
    public void shouldRetryReturnsTrueForExhaustedResourcedError() {
        Athena2QueryHelper helper = athena2QueryHelperWithRetry("retryable");
        assertTrue(helper.shouldRetry(
                newGetQueryExecutionResponse(QueryExecutionState.FAILED, "exhausted resources at this scale factor")));
    }