Skip to content

Commit

Permalink
support simple
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Mar 21, 2024
1 parent 9263b90 commit b83bcc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions velox/expression/tests/utils/ArgumentTypeFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>()(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<uint32_t>(1, 38)(rng_);
Expand All @@ -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<uint32_t>(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<uint32_t>(
0, precision)(rng_);
}
} else {
integerVariablesBindings_[variableName] =
boost::random::uniform_int_distribution<int32_t>()(rng_);
}
}

Expand Down
1 change: 1 addition & 0 deletions velox/type/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename P, typename S>
struct ShortDecimal {
Expand Down

0 comments on commit b83bcc8

Please sign in to comment.