From 64f9618c36c60ccbc2094f21ff86bf51b7c5bb2c Mon Sep 17 00:00:00 2001 From: Wei He Date: Wed, 20 Mar 2024 18:17:41 -0700 Subject: [PATCH] Fix exception thrown in custom result verifier in WindowFuzzer (#9189) Summary: Pull Request resolved: https://github.com/facebookincubator/velox/pull/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 --- velox/exec/fuzzer/WindowFuzzer.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/velox/exec/fuzzer/WindowFuzzer.cpp b/velox/exec/fuzzer/WindowFuzzer.cpp index 13a38ef72119..3d73cbaa676e 100644 --- a/velox/exec/fuzzer/WindowFuzzer.cpp +++ b/velox/exec/fuzzer/WindowFuzzer.cpp @@ -384,20 +384,18 @@ bool WindowFuzzer::verifyWindow( bool customVerification, const std::shared_ptr& 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_); } @@ -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); } }