@@ -220,6 +220,10 @@ void WindowFuzzer::go() {
220
220
221
221
const bool customVerification =
222
222
customVerificationFunctions_.count (signature.name ) != 0 ;
223
+ std::shared_ptr<ResultVerifier> customVerifier = nullptr ;
224
+ if (customVerification) {
225
+ customVerifier = customVerificationFunctions_.at (signature.name );
226
+ }
223
227
const bool requireSortedInput =
224
228
orderDependentFunctions_.count (signature.name ) != 0 ;
225
229
@@ -257,6 +261,7 @@ void WindowFuzzer::go() {
257
261
call,
258
262
input,
259
263
customVerification,
264
+ customVerifier,
260
265
FLAGS_enable_window_reference_verification);
261
266
if (failed) {
262
267
signatureWithStats.second .numFailed ++;
@@ -292,6 +297,7 @@ void WindowFuzzer::testAlternativePlans(
292
297
const std::string& functionCall,
293
298
const std::vector<RowVectorPtr>& input,
294
299
bool customVerification,
300
+ const std::shared_ptr<ResultVerifier>& customVerifier,
295
301
const velox::test::ResultOrError& expected) {
296
302
std::vector<AggregationFuzzerBase::PlanWithSplits> plans;
297
303
@@ -348,28 +354,47 @@ void WindowFuzzer::testAlternativePlans(
348
354
349
355
for (const auto & plan : plans) {
350
356
testPlan (
351
- plan,
352
- false ,
353
- false ,
354
- customVerification,
355
- /* customVerifiers*/ {},
356
- expected);
357
+ plan, false , false , customVerification, {customVerifier}, expected);
357
358
}
358
359
}
359
360
361
+ namespace {
362
+ void initializeVerifier (
363
+ const core::PlanNodePtr& plan,
364
+ const std::shared_ptr<ResultVerifier>& customVerifier,
365
+ const std::vector<RowVectorPtr>& input,
366
+ const std::vector<std::string>& partitionKeys,
367
+ const std::string& frame) {
368
+ const auto & windowNode =
369
+ std::dynamic_pointer_cast<const core::WindowNode>(plan);
370
+ customVerifier->initializeWindow (
371
+ input, partitionKeys, windowNode->windowFunctions ()[0 ], frame, " w0" );
372
+ }
373
+ } // namespace
374
+
360
375
bool WindowFuzzer::verifyWindow (
361
376
const std::vector<std::string>& partitionKeys,
362
377
const std::vector<SortingKeyAndOrder>& sortingKeysAndOrders,
363
378
const std::string& frameClause,
364
379
const std::string& functionCall,
365
380
const std::vector<RowVectorPtr>& input,
366
381
bool customVerification,
382
+ const std::shared_ptr<ResultVerifier>& customVerifier,
367
383
bool enableWindowVerification) {
368
384
auto frame = getFrame (partitionKeys, sortingKeysAndOrders, frameClause);
369
385
auto plan = PlanBuilder ()
370
386
.values (input)
371
387
.window ({fmt::format (" {} over ({})" , functionCall, frame)})
372
388
.planNode ();
389
+ if (customVerifier) {
390
+ initializeVerifier (plan, customVerifier, input, partitionKeys, frame);
391
+ }
392
+ SCOPE_EXIT {
393
+ if (customVerifier) {
394
+ customVerifier->reset ();
395
+ }
396
+ };
397
+
373
398
if (persistAndRunOnce_) {
374
399
persistReproInfo ({{plan, {}}}, reproPersistPath_);
375
400
}
@@ -381,8 +406,8 @@ bool WindowFuzzer::verifyWindow(
381
406
++stats_.numFailed ;
382
407
}
383
408
384
- if (!customVerification && enableWindowVerification ) {
385
- if (resultOrError.result ) {
409
+ if (!customVerification) {
410
+ if (resultOrError.result && enableWindowVerification ) {
386
411
auto referenceResult = computeReferenceResults (plan, input);
387
412
stats_.updateReferenceQueryStats (referenceResult.second );
388
413
if (auto expectedResult = referenceResult.first ) {
@@ -399,9 +424,15 @@ bool WindowFuzzer::verifyWindow(
399
424
}
400
425
}
401
426
} else {
402
- // TODO: support custom verification.
403
- LOG (INFO) << " Verification skipped" ;
427
+ LOG (INFO) << " Verification through custom verifier" ;
404
428
++stats_.numVerificationSkipped ;
429
+
430
+ if (customVerifier && resultOrError.result ) {
431
+ VELOX_CHECK (
432
+ customVerifier->supportsVerify (),
433
+ " Window fuzzer only uses custom verify() methods." );
434
+ customVerifier->verify (resultOrError.result );
435
+ }
405
436
}
406
437
407
438
testAlternativePlans (
@@ -411,6 +442,7 @@ bool WindowFuzzer::verifyWindow(
411
442
functionCall,
412
443
input,
413
444
customVerification,
445
+ customVerifier,
414
446
resultOrError);
415
447
416
448
return resultOrError.exceptionPtr != nullptr ;
0 commit comments