-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Verifier] Support reuse of source query output table #22169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,8 @@ public VerificationResult run() | |
| ChecksumQueryContext testChecksumQueryContext = new ChecksumQueryContext(); | ||
| Optional<R> matchResult = Optional.empty(); | ||
| Optional<DeterminismAnalysisDetails> determinismAnalysisDetails = Optional.empty(); | ||
| boolean controlReuseTable = false; | ||
| boolean testReuseTable = false; | ||
|
|
||
| Optional<PartialVerificationResult> partialResult = Optional.empty(); | ||
| Optional<Throwable> throwable = Optional.empty(); | ||
|
|
@@ -204,52 +206,74 @@ public VerificationResult run() | |
| // Rewrite queries | ||
| if (isControlEnabled()) { | ||
| control = Optional.of(getQueryRewrite(CONTROL)); | ||
| controlReuseTable = control.isPresent() && control.get() instanceof QueryObjectBundle && ((QueryObjectBundle) control.get()).isReuseTable(); | ||
| if (controlReuseTable) { | ||
| controlQueryContext.setState(QueryState.REUSE); | ||
| controlQueryContext.setMainQueryStats(QueryActionStats.queryIdStats(sourceQuery.getQueryId(CONTROL).get())); | ||
| } | ||
| } | ||
|
|
||
| test = Optional.of(getQueryRewrite(TEST)); | ||
| testReuseTable = test.isPresent() && test.get() instanceof QueryObjectBundle && ((QueryObjectBundle) test.get()).isReuseTable(); | ||
| if (testReuseTable) { | ||
| testQueryContext.setState(QueryState.REUSE); | ||
| testQueryContext.setMainQueryStats(QueryActionStats.queryIdStats(sourceQuery.getQueryId(TEST).get())); | ||
| } | ||
|
Comment on lines
+217
to
+221
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
|
|
||
| // First run setup queries | ||
| if (isControlEnabled()) { | ||
| if (isControlEnabled() && !controlReuseTable) { | ||
| QueryBundle controlQueryBundle = control.get(); | ||
| QueryAction controlSetupAction = setupOnMainClusters ? queryActions.getControlAction() : queryActions.getHelperAction(); | ||
| controlQueryBundle.getSetupQueries().forEach(query -> runAndConsume( | ||
| () -> controlSetupAction.execute(query, CONTROL_SETUP), | ||
| controlQueryContext::addSetupQuery, | ||
| controlQueryContext::setException)); | ||
| } | ||
| QueryBundle testQueryBundle = test.get(); | ||
| QueryAction testSetupAction = setupOnMainClusters ? queryActions.getTestAction() : queryActions.getHelperAction(); | ||
| testQueryBundle.getSetupQueries().forEach(query -> runAndConsume( | ||
| () -> testSetupAction.execute(query, TEST_SETUP), | ||
| testQueryContext::addSetupQuery, | ||
| testQueryContext::setException)); | ||
| if (!testReuseTable) { | ||
| QueryBundle testQueryBundle = test.get(); | ||
| QueryAction testSetupAction = setupOnMainClusters ? queryActions.getTestAction() : queryActions.getHelperAction(); | ||
| testQueryBundle.getSetupQueries().forEach(query -> runAndConsume( | ||
| () -> testSetupAction.execute(query, TEST_SETUP), | ||
| testQueryContext::addSetupQuery, | ||
| testQueryContext::setException)); | ||
| } | ||
|
|
||
| ListenableFuture<Optional<QueryResult<V>>> controlQueryFuture = immediateFuture(Optional.empty()); | ||
| ListenableFuture<Optional<QueryResult<V>>> testQueryFuture = immediateFuture(Optional.empty()); | ||
| // Start control query | ||
| if (isControlEnabled()) { | ||
| if (isControlEnabled() && !controlReuseTable) { | ||
| QueryBundle controlQueryBundle = control.get(); | ||
| controlQueryFuture = executor.submit(() -> runMainQuery(controlQueryBundle.getQuery(), CONTROL, controlQueryContext)); | ||
| } | ||
|
|
||
| if (!concurrentControlAndTest) { | ||
| getFutureValue(controlQueryFuture); | ||
| } | ||
|
|
||
| // Run test queries | ||
| ListenableFuture<Optional<QueryResult<V>>> testQueryFuture = executor.submit(() -> runMainQuery(testQueryBundle.getQuery(), TEST, testQueryContext)); | ||
| if (!testReuseTable) { | ||
| QueryBundle testQueryBundle = test.get(); | ||
| testQueryFuture = executor.submit(() -> runMainQuery(testQueryBundle.getQuery(), TEST, testQueryContext)); | ||
| } | ||
| controlQueryResult = getFutureValue(controlQueryFuture); | ||
|
|
||
| if (QUERY_BANK_MODE.equals(runningMode) && !saveSnapshot) { | ||
| controlQueryContext.setState(QueryState.SUCCEEDED); | ||
| controlQueryContext.setMainQueryStats(EMPTY_STATS); | ||
| } | ||
| else if (!skipControl || QUERY_BANK_MODE.equals(runningMode)) { | ||
| // saveSnapshot or regular run with skipControl = false | ||
| controlQueryContext.setState(QueryState.SUCCEEDED); | ||
| if (!controlReuseTable) { | ||
| controlQueryContext.setState(QueryState.SUCCEEDED); | ||
| } | ||
| } | ||
| else { | ||
| controlQueryContext.setState(NOT_RUN); | ||
| } | ||
|
|
||
| testQueryResult = getFutureValue(testQueryFuture); | ||
| testQueryContext.setState(QueryState.SUCCEEDED); | ||
| if (!testReuseTable) { | ||
| testQueryContext.setState(QueryState.SUCCEEDED); | ||
| } | ||
|
|
||
| // Verify results | ||
| if (QUERY_BANK_MODE.equals(runningMode) && !saveSnapshot && !skipChecksum) { | ||
|
|
@@ -262,8 +286,13 @@ else if ((isControlEnabled()) && !skipChecksum) { | |
| matchResult = Optional.of(verify(control.get(), test.get(), controlQueryResult, testQueryResult, controlChecksumQueryContext, testChecksumQueryContext)); | ||
|
|
||
| // Determinism analysis | ||
| if (!QUERY_BANK_MODE.equals(runningMode) && matchResult.get().isMismatchPossiblyCausedByNonDeterminism()) { | ||
| determinismAnalysisDetails = Optional.of(analyzeDeterminism(control.get(), matchResult.get())); | ||
| if (!QUERY_BANK_MODE.equals(runningMode)) { | ||
| if ((controlReuseTable || testReuseTable) && matchResult.get().isMismatchPossiblyCausedByReuseOutdatedTable() && verificationContext.getResubmissionCount() < verificationResubmissionLimit) { | ||
| return new VerificationResult(this, true, Optional.empty()); | ||
| } | ||
| else if (matchResult.get().isMismatchPossiblyCausedByNonDeterminism()) { | ||
| determinismAnalysisDetails = Optional.of(analyzeDeterminism(control.get(), matchResult.get())); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -287,7 +316,7 @@ else if ((isControlEnabled()) && !skipChecksum) { | |
| } | ||
| finally { | ||
| if (!smartTeardown | ||
| || testQueryContext.getState() != QueryState.SUCCEEDED | ||
| || !ImmutableList.of(QueryState.SUCCEEDED, QueryState.REUSE).contains(testQueryContext.getState()) | ||
| || (partialResult.isPresent() && partialResult.get().getStatus().equals(SUCCEEDED))) { | ||
| QueryAction controlTeardownAction = teardownOnMainClusters ? queryActions.getControlAction() : queryActions.getHelperAction(); | ||
| QueryAction testTeardownAction = teardownOnMainClusters ? queryActions.getTestAction() : queryActions.getHelperAction(); | ||
|
|
@@ -347,13 +376,14 @@ private EventStatus getEventStatus( | |
| } | ||
|
|
||
| if (skipControl) { | ||
| if (testQueryContext.getState() == QueryState.SUCCEEDED) { | ||
| if (ImmutableList.of(QueryState.SUCCEEDED, QueryState.REUSE).contains(testQueryContext.getState())) { | ||
| return SUCCEEDED; | ||
| } | ||
| } | ||
| else { | ||
| if (skipChecksum) { | ||
| if (controlQueryContext.getState() == QueryState.SUCCEEDED && testQueryContext.getState() == QueryState.SUCCEEDED) { | ||
| if (ImmutableList.of(QueryState.SUCCEEDED, QueryState.REUSE).contains(testQueryContext.getState()) && | ||
| ImmutableList.of(QueryState.SUCCEEDED, QueryState.REUSE).contains(controlQueryContext.getState())) { | ||
| return SUCCEEDED; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer to put the logic inside the getQueryRewrite()