| 141 | for (auto& signature : signatures) { |
| 142 | hasSupportedSignature |= addSignature(name, signature); |
| 143 | } |
| 144 | if (hasSupportedSignature) { |
| 145 | ++functionsStats.numSupportedFunctions; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | std::pair<CallableSignature, AggregationFuzzerBase::SignatureStats&> |
| 151 | AggregationFuzzerBase::pickSignature() { |
| 152 | size_t idx = boost::random::uniform_int_distribution<uint32_t>( |
| 153 | 0, signatures_.size() + signatureTemplates_.size() - 1)(rng_); |
| 154 | CallableSignature signature; |
| 155 | if (idx < signatures_.size()) { |
| 156 | signature = signatures_[idx]; |
| 157 | } else { |
| 158 | const auto& signatureTemplate = |
| 159 | signatureTemplates_[idx - signatures_.size()]; |
| 160 | signature.name = signatureTemplate.name; |
| 161 | bolt::fuzzer::ArgumentTypeFuzzer typeFuzzer( |
| 162 | *signatureTemplate.signature, rng_); |
| 163 | BOLT_CHECK(typeFuzzer.fuzzArgumentTypes(FLAGS_bolt_fuzzer_max_num_varargs)); |
| 164 | signature.args = typeFuzzer.argumentTypes(); |
| 165 | } |
| 166 | |
| 167 | return {signature, signatureStats_[idx]}; |
| 168 | } |
| 169 | |
| 170 | std::vector<std::string> AggregationFuzzerBase::generateKeys( |
| 171 | const std::string& prefix, |
| 172 | std::vector<std::string>& names, |
| 173 | std::vector<TypePtr>& types) { |
| 174 | static const std::vector<TypePtr> kNonFloatingPointTypes{ |
| 175 | BOOLEAN(), |
| 176 | TINYINT(), |
| 177 | SMALLINT(), |
| 178 | INTEGER(), |
| 179 | BIGINT(), |
| 180 | VARCHAR(), |
| 181 | VARBINARY(), |
| 182 | TIMESTAMP(), |
| 183 | }; |
| 184 | |
| 185 | auto numKeys = boost::random::uniform_int_distribution<uint32_t>(1, 5)(rng_); |
| 186 | std::vector<std::string> keys; |
| 187 | for (auto i = 0; i < numKeys; ++i) { |
| 188 | keys.push_back(fmt::format("{}{}", prefix, i)); |
| 189 | |
| 190 | // Pick random, possibly complex, type. |
| 191 | types.push_back(vectorFuzzer_.randType(kNonFloatingPointTypes, 2)); |
| 192 | names.push_back(keys.back()); |
| 193 | } |
| 194 | return keys; |
| 195 | } |
| 196 | |
| 197 | std::vector<std::string> AggregationFuzzerBase::generateSortingKeys( |
| 198 | const std::string& prefix, |
| 199 | std::vector<std::string>& names, |
| 200 | std::vector<TypePtr>& types) { |
nothing calls this directly
no test coverage detected