From 59d474139ccbde18df7ea1c46efae833067156ce Mon Sep 17 00:00:00 2001 From: Bikramjeet Vig Date: Tue, 10 Dec 2024 22:29:22 -0800 Subject: [PATCH] fix(fuzzer): Ensure common dictionary generation skips row_number column (#11821) Summary: Ensure that the row_number column, used for lining up results with the reference database, is not treated as a candidate for wrapping by the fuzzer's feature that probabilistically adds a common dictionary layer. This prevents verification mismatches caused by the column being wrapped and losing its intended purpose. Pull Request resolved: https://github.com/facebookincubator/velox/pull/11821 Reviewed By: kagamiori Differential Revision: D67071154 Pulled By: bikramSingh91 fbshipit-source-id: 8051d264873fb74bc27064a64027ec72448131ad --- .../fuzzer/ExpressionFuzzerVerifier.cpp | 16 +++++++--------- .../expression/fuzzer/ExpressionFuzzerVerifier.h | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/velox/expression/fuzzer/ExpressionFuzzerVerifier.cpp b/velox/expression/fuzzer/ExpressionFuzzerVerifier.cpp index ddae30f11f0e..1ede9f9cccb9 100644 --- a/velox/expression/fuzzer/ExpressionFuzzerVerifier.cpp +++ b/velox/expression/fuzzer/ExpressionFuzzerVerifier.cpp @@ -321,17 +321,15 @@ void ExpressionFuzzerVerifier::retryWithTry( } } -RowVectorPtr ExpressionFuzzerVerifier::fuzzInputWithRowNumber( - VectorFuzzer& fuzzer, - const RowTypePtr& type) { - auto rowVector = fuzzer.fuzzInputRow(type); - auto names = type->names(); +RowVectorPtr ExpressionFuzzerVerifier::appendRowNumberColumn( + RowVectorPtr& inputRow) { + auto names = asRowType(inputRow->type())->names(); names.push_back("row_number"); - auto& children = rowVector->children(); + auto& children = inputRow->children(); velox::test::VectorMaker vectorMaker{pool_.get()}; children.push_back(vectorMaker.flatVector( - rowVector->size(), [&](auto row) { return row; })); + inputRow->size(), [&](auto row) { return row; })); return vectorMaker.rowVector(names, children); } @@ -375,10 +373,10 @@ void ExpressionFuzzerVerifier::go() { std::vector plans = std::move(expressions); - auto rowVector = fuzzInputWithRowNumber(*vectorFuzzer_, inputType); - + auto rowVector = vectorFuzzer_->fuzzInputRow(inputType); InputRowMetadata inputRowMetadata = generateInputRowMetadata(rowVector, *vectorFuzzer_); + rowVector = appendRowNumberColumn(rowVector); auto resultVectors = generateResultVectors(plans); ResultOrError result; diff --git a/velox/expression/fuzzer/ExpressionFuzzerVerifier.h b/velox/expression/fuzzer/ExpressionFuzzerVerifier.h index c03de0de2b3d..aaf6d7d5cdce 100644 --- a/velox/expression/fuzzer/ExpressionFuzzerVerifier.h +++ b/velox/expression/fuzzer/ExpressionFuzzerVerifier.h @@ -201,10 +201,10 @@ class ExpressionFuzzerVerifier { const RowVectorPtr& rowVector, VectorFuzzer& vectorFuzzer); - // Fuzzes the input vector of type with an additional row number column. - RowVectorPtr fuzzInputWithRowNumber( - VectorFuzzer& fuzzer, - const RowTypePtr& type); + // Appends an additional row number column called 'row_number' at the end of + // the 'inputRow'. This column is then used to line up rows when comparing + // results against a reference database. + RowVectorPtr appendRowNumberColumn(RowVectorPtr& inputRow); const Options options_;