diff --git a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DeterminismAnalyzer.java b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DeterminismAnalyzer.java index 723f1986000b..ff541f5fd2a0 100644 --- a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DeterminismAnalyzer.java +++ b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DeterminismAnalyzer.java @@ -40,7 +40,6 @@ import static com.facebook.presto.verifier.framework.DataVerificationUtil.getColumns; import static com.facebook.presto.verifier.framework.DataVerificationUtil.match; import static com.facebook.presto.verifier.framework.DataVerificationUtil.teardownSafely; -import static com.facebook.presto.verifier.framework.DeterminismAnalysis.ANALYSIS_FAILED; import static com.facebook.presto.verifier.framework.DeterminismAnalysis.ANALYSIS_FAILED_DATA_CHANGED; import static com.facebook.presto.verifier.framework.DeterminismAnalysis.ANALYSIS_FAILED_INCONSISTENT_SCHEMA; import static com.facebook.presto.verifier.framework.DeterminismAnalysis.ANALYSIS_FAILED_QUERY_FAILURE; @@ -98,11 +97,33 @@ protected DeterminismAnalysis analyze(QueryBundle control, ChecksumResult contro return NON_DETERMINISTIC_CATALOG; } + // Handle limit query + LimitQueryDeterminismAnalysis limitQueryAnalysis = new LimitQueryDeterminismAnalyzer( + prestoAction, + handleLimitQuery, + control.getQuery(), + controlChecksum.getRowCount(), + determinismAnalysisDetails).analyze(); + + switch (limitQueryAnalysis) { + case NOT_RUN: + case FAILED_QUERY_FAILURE: + // try the next analysis + break; + case NON_DETERMINISTIC: + return NON_DETERMINISTIC_LIMIT_CLAUSE; + case DETERMINISTIC: + return DETERMINISTIC; + case FAILED_DATA_CHANGED: + return ANALYSIS_FAILED_DATA_CHANGED; + default: + throw new IllegalArgumentException(format("Invalid limitQueryAnalysis: %s", limitQueryAnalysis)); + } + + // Rerun control query multiple times List columns = getColumns(prestoAction, typeManager, control.getTableName()); Map queryRuns = new HashMap<>(); - try { - // Rerun control query for (int i = 0; i < maxAnalysisRuns; i++) { QueryBundle queryBundle = queryRewriter.rewriteQuery(sourceQuery.getControlQuery(), CONTROL); DeterminismAnalysisRun.Builder run = determinismAnalysisDetails.addRun().setTableName(queryBundle.getTableName().toString()); @@ -128,32 +149,11 @@ protected DeterminismAnalysis analyze(QueryBundle control, ChecksumResult contro } } - // Handle limit query - LimitQueryDeterminismAnalysis limitQueryAnalysis = new LimitQueryDeterminismAnalyzer( - prestoAction, - handleLimitQuery, - control.getQuery(), - controlChecksum.getRowCount(), - determinismAnalysisDetails).analyze(); - - switch (limitQueryAnalysis) { - case NON_DETERMINISTIC: - return NON_DETERMINISTIC_LIMIT_CLAUSE; - case NOT_RUN: - case DETERMINISTIC: - return DETERMINISTIC; - case FAILED_DATA_CHANGED: - return ANALYSIS_FAILED_DATA_CHANGED; - default: - throw new IllegalArgumentException(format("Invalid limitQueryAnalysis: %s", limitQueryAnalysis)); - } + return DETERMINISTIC; } catch (QueryException qe) { return ANALYSIS_FAILED_QUERY_FAILURE; } - catch (Throwable t) { - return ANALYSIS_FAILED; - } finally { if (runTeardown) { queryRuns.forEach((queryBundle, run) -> teardownSafely( diff --git a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalysis.java b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalysis.java index c017ce5d5fe0..7980b0e348c0 100644 --- a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalysis.java +++ b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalysis.java @@ -19,4 +19,5 @@ public enum LimitQueryDeterminismAnalysis NON_DETERMINISTIC, DETERMINISTIC, FAILED_DATA_CHANGED, + FAILED_QUERY_FAILURE, } diff --git a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalyzer.java b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalyzer.java index 1a8edd2464a1..d3a63961eb93 100644 --- a/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalyzer.java +++ b/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/LimitQueryDeterminismAnalyzer.java @@ -46,6 +46,7 @@ import static com.facebook.presto.sql.QueryUtil.simpleQuery; import static com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.DETERMINISTIC; import static com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.FAILED_DATA_CHANGED; +import static com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.FAILED_QUERY_FAILURE; import static com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.NON_DETERMINISTIC; import static com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.NOT_RUN; import static com.facebook.presto.verifier.framework.QueryStage.DETERMINISM_ANALYSIS_MAIN; @@ -89,7 +90,14 @@ public LimitQueryDeterminismAnalyzer( public LimitQueryDeterminismAnalysis analyze() { - LimitQueryDeterminismAnalysis analysis = analyzeInternal(); + LimitQueryDeterminismAnalysis analysis; + try { + analysis = analyzeInternal(); + } + catch (QueryException queryException) { + analysis = FAILED_QUERY_FAILURE; + } + determinismAnalysisDetails.setLimitQueryAnalysis(analysis); return analysis; }