Skip to content

Commit

Permalink
Add option to limit input size in expression fuzzer
Browse files Browse the repository at this point in the history
Summary:
Add the option maxInputsThreshold to ExpressionFuzzer::options
when maxInputsThreshold is true, if the input size is reached to maxInputsThreshold, then 
when fuzzing new input columns, if an already fuzzed column of the same type exists then it will be used
instead of fuzzing new one. 


This is needed for some internal meta fuzzer tests where input size used to blow up.

Differential Revision: D52642521
  • Loading branch information
laithsakka authored and facebook-github-bot committed Jan 9, 2024
1 parent 4fd8186 commit e163452
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions velox/expression/tests/ExpressionFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,12 @@ core::TypedExprPtr ExpressionFuzzer::generateArgColumn(const TypePtr& arg) {
auto& listOfCandidateCols = state.typeToColumnNames_[arg->toString()];
bool reuseColumn = options_.enableColumnReuse &&
!listOfCandidateCols.empty() && vectorFuzzer_->coinToss(0.3);

if (!reuseColumn && options_.maxInputsThreshold.has_value() &&
state.inputRowTypes_.size() >= options_.maxInputsThreshold.value()) {
reuseColumn = !listOfCandidateCols.empty();
}

if (!reuseColumn) {
state.inputRowTypes_.emplace_back(arg);
state.inputRowNames_.emplace_back(
Expand Down
7 changes: 7 additions & 0 deletions velox/expression/tests/ExpressionFuzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ class ExpressionFuzzer {
// "width_bucket",
// "array_sort(array(T),constant function(T,T,bigint)) -> array(T)"}
std::unordered_set<std::string> skipFunctions;

// When set, when the input size of the generated expressions reaches
// maxInputsThreshold, fuzzing input columns will reuse one of the existing
// columns if any is already generated with the same type.
// This can be used to control the size of the input of the fuzzer
// expression.
std::optional<int32_t> maxInputsThreshold = std::nullopt;
};

ExpressionFuzzer(
Expand Down

0 comments on commit e163452

Please sign in to comment.