diff --git a/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp b/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp index 3cfe7bf4b7345..38535ed0e6783 100644 --- a/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp +++ b/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp @@ -46,10 +46,7 @@ void ArgumentTypeFuzzer::determineUnboundedIntegerVariables() { continue; } - if (auto pos = variableName.find("precision"); pos == std::string::npos) { - integerVariablesBindings_[variableName] = - boost::random::uniform_int_distribution()(rng_); - } else { + if (auto pos = variableName.find("precision"); pos != std::string::npos) { // Handle decimal precisions and scales. const auto precision = boost::random::uniform_int_distribution(1, 38)(rng_); @@ -63,6 +60,21 @@ void ArgumentTypeFuzzer::determineUnboundedIntegerVariables() { 0, precision)(rng_); } } + } else if (auto pos = variableName.find("i"); pos != std::string::npos) { + auto index = std::stoi(variableName.substr(pos, variableName.size())); + if (index <= kIntegerPairSize) { + const auto precision = + boost::random::uniform_int_distribution(1, 38)(rng_); + integerVariablesBindings_[variableName] = precision; + const auto scaleIndex = index + kIntegerPairSize; + const auto scaleName = "i" + std::to_string(scaleIndex); + integerVariablesBindings_[scaleName] = + boost::random::uniform_int_distribution( + 0, precision)(rng_); + } + } else { + integerVariablesBindings_[variableName] = + boost::random::uniform_int_distribution()(rng_); } } diff --git a/velox/type/Type.h b/velox/type/Type.h index 8167fffdc853b..24d4bf295f9a5 100644 --- a/velox/type/Type.h +++ b/velox/type/Type.h @@ -1760,6 +1760,7 @@ using S1 = IntegerVariable<5>; using S2 = IntegerVariable<6>; using S3 = IntegerVariable<7>; using S4 = IntegerVariable<8>; +const uint8_t kIntegerPairSize = 4; template struct ShortDecimal {