@@ -48,6 +48,7 @@ class AggregationFuzzer : public AggregationFuzzerBase {
48
48
AggregationFuzzer (
49
49
AggregateFunctionSignatureMap signatureMap,
50
50
size_t seed,
51
+ const std::unordered_set<std::string>& functionsRequireSortedInput,
51
52
const std::unordered_map<std::string, std::shared_ptr<ResultVerifier>>&
52
53
customVerificationFunctions,
53
54
const std::unordered_map<std::string, std::shared_ptr<InputGenerator>>&
@@ -183,14 +184,18 @@ class AggregationFuzzer : public AggregationFuzzerBase {
183
184
}
184
185
}
185
186
187
+ bool mustSortInput (const CallableSignature& signature) const ;
188
+
186
189
Stats stats_;
187
190
const std::unordered_map<std::string, DataSpec> functionDataSpec_;
191
+ const std::unordered_set<std::string> functionsRequireSortedInput_;
188
192
};
189
193
} // namespace
190
194
191
195
void aggregateFuzzer (
192
196
AggregateFunctionSignatureMap signatureMap,
193
197
size_t seed,
198
+ const std::unordered_set<std::string>& functionsRequireSortedInput,
194
199
const std::unordered_map<std::string, std::shared_ptr<ResultVerifier>>&
195
200
customVerificationFunctions,
196
201
const std::unordered_map<std::string, std::shared_ptr<InputGenerator>>&
@@ -205,6 +210,7 @@ void aggregateFuzzer(
205
210
auto aggregationFuzzer = AggregationFuzzer (
206
211
std::move (signatureMap),
207
212
seed,
213
+ functionsRequireSortedInput,
208
214
customVerificationFunctions,
209
215
customInputGenerators,
210
216
functionDataSpec,
@@ -222,6 +228,7 @@ namespace {
222
228
AggregationFuzzer::AggregationFuzzer (
223
229
AggregateFunctionSignatureMap signatureMap,
224
230
size_t seed,
231
+ const std::unordered_set<std::string>& functionsRequireSortedInput,
225
232
const std::unordered_map<std::string, std::shared_ptr<ResultVerifier>>&
226
233
customVerificationFunctions,
227
234
const std::unordered_map<std::string, std::shared_ptr<InputGenerator>>&
@@ -233,7 +240,8 @@ AggregationFuzzer::AggregationFuzzer(
233
240
bool orderableGroupKeys,
234
241
std::unique_ptr<ReferenceQueryRunner> referenceQueryRunner)
235
242
: AggregationFuzzerBase{seed, customVerificationFunctions, customInputGenerators, timestampPrecision, queryConfigs, hiveConfigs, orderableGroupKeys, std::move (referenceQueryRunner)},
236
- functionDataSpec_{functionDataSpec} {
243
+ functionDataSpec_{functionDataSpec},
244
+ functionsRequireSortedInput_{functionsRequireSortedInput} {
237
245
VELOX_CHECK (!signatureMap.empty (), " No function signatures available." );
238
246
239
247
if (persistAndRunOnce_ && reproPersistPath_.empty ()) {
@@ -309,6 +317,11 @@ bool supportsDistinctInputs(
309
317
return arg->isComparable ();
310
318
}
311
319
320
+ bool AggregationFuzzer::mustSortInput (
321
+ const CallableSignature& signature) const {
322
+ return functionsRequireSortedInput_.count (signature.name ) > 0 ;
323
+ }
324
+
312
325
void AggregationFuzzer::go () {
313
326
VELOX_CHECK (
314
327
FLAGS_steps > 0 || FLAGS_duration_sec > 0 ,
@@ -338,6 +351,13 @@ void AggregationFuzzer::go() {
338
351
} else {
339
352
// Pick a random signature.
340
353
auto signatureWithStats = pickSignature ();
354
+ auto signature = signatureWithStats.first ;
355
+ if (mustSortInput (signature) &&
356
+ !(FLAGS_enable_sorted_aggregations && canSortInputs (signature))) {
357
+ continue ;
358
+ }
359
+ signatureWithStats.second .numRuns ++;
360
+ stats_.functionNames .insert (signature.name );
341
361
342
362
if (functionDataSpec_.count (signatureWithStats.first .name ) > 0 ) {
343
363
vectorOptions.dataSpec =
@@ -347,19 +367,10 @@ void AggregationFuzzer::go() {
347
367
vectorOptions.dataSpec = {true , true };
348
368
}
349
369
vectorFuzzer_.setOptions (vectorOptions);
350
- signatureWithStats.second .numRuns ++;
351
370
352
- auto signature = signatureWithStats.first ;
353
- stats_.functionNames .insert (signature.name );
354
-
355
- const bool customVerification =
356
- customVerificationFunctions_.count (signature.name ) != 0 ;
357
-
358
- std::vector<TypePtr> argTypes = signature.args ;
359
- std::vector<std::string> argNames = makeNames (argTypes.size ());
360
-
361
- const bool sortedInputs = FLAGS_enable_sorted_aggregations &&
362
- canSortInputs (signature) && vectorFuzzer_.coinToss (0.2 );
371
+ const bool sortedInputs = mustSortInput (signature) ||
372
+ (FLAGS_enable_sorted_aggregations && canSortInputs (signature) &&
373
+ vectorFuzzer_.coinToss (0.2 ));
363
374
364
375
// Exclude approx_xxx aggregations since their verifiers may not be able
365
376
// to verify the results. The approx_percentile verifier would discard
@@ -372,6 +383,8 @@ void AggregationFuzzer::go() {
372
383
supportsDistinctInputs (signature, orderableGroupKeys_) &&
373
384
vectorFuzzer_.coinToss (0.2 );
374
385
386
+ std::vector<TypePtr> argTypes = signature.args ;
387
+ std::vector<std::string> argNames = makeNames (argTypes.size ());
375
388
auto call = makeFunctionCall (
376
389
signature.name , argNames, sortedInputs, distinctInputs);
377
390
@@ -398,6 +411,8 @@ void AggregationFuzzer::go() {
398
411
399
412
logVectors (input);
400
413
414
+ const bool customVerification =
415
+ customVerificationFunctions_.count (signature.name ) != 0 ;
401
416
std::shared_ptr<ResultVerifier> customVerifier;
402
417
if (customVerification) {
403
418
customVerifier = customVerificationFunctions_.at (signature.name );
0 commit comments