Skip to content

Commit

Permalink
Fix exception thrown in custom result verifier in WindowFuzzer (faceb…
Browse files Browse the repository at this point in the history
…ookincubator#9189)

Summary:
Pull Request resolved: facebookincubator#9189

The window fuzzer sometimes test functions with invalid frames (e.g., with negative frame
start or end). In this situation, the execution of the query is expected to throw. With the
current code, however, if the function uses custom result verifier, the verifier initialization
throws too and cause a test failure. This diff fixes the test failures caused by exception
thrown in custom verifier by initializing it only when the main query succeed.

Reviewed By: kgpai

Differential Revision: D55160430

fbshipit-source-id: f104992e94fd0328eda97667e8bb7de38fdce7d2
  • Loading branch information
kagamiori authored and facebook-github-bot committed Mar 21, 2024
1 parent 3db2a9a commit 64f9618
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions velox/exec/fuzzer/WindowFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,18 @@ bool WindowFuzzer::verifyWindow(
bool customVerification,
const std::shared_ptr<ResultVerifier>& customVerifier,
bool enableWindowVerification) {
auto frame = getFrame(partitionKeys, sortingKeysAndOrders, frameClause);
auto plan = PlanBuilder()
.values(input)
.window({fmt::format("{} over ({})", functionCall, frame)})
.planNode();
if (customVerifier) {
initializeVerifier(plan, customVerifier, input, partitionKeys, frame);
}
SCOPE_EXIT {
if (customVerifier) {
customVerifier->reset();
}
};

auto frame = getFrame(partitionKeys, sortingKeysAndOrders, frameClause);
auto plan = PlanBuilder()
.values(input)
.window({fmt::format("{} over ({})", functionCall, frame)})
.planNode();

if (persistAndRunOnce_) {
persistReproInfo({{plan, {}}}, reproPersistPath_);
}
Expand Down Expand Up @@ -434,6 +432,7 @@ bool WindowFuzzer::verifyWindow(
VELOX_CHECK(
customVerifier->supportsVerify(),
"Window fuzzer only uses custom verify() methods.");
initializeVerifier(plan, customVerifier, input, partitionKeys, frame);
customVerifier->verify(resultOrError.result);
}
}
Expand Down

0 comments on commit 64f9618

Please sign in to comment.