Skip to content

Commit

Permalink
sql: disable agg funcs in costfuzz and unoptimized query oracle
Browse files Browse the repository at this point in the history
The false-positives of costfuzz and unoptimized-query-oracle caused by
aggregate functions are overwhelming. This commit prevents aggregate
functions from being generated for these tests.

Informs cockroachdb#87353

Release justification: This is a test-only change.

Release note: None
  • Loading branch information
mgartner committed Sep 6, 2022
1 parent 47069e9 commit 8b546f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cmd/roachtest/tests/query_comparison_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ func runOneRoundQueryComparison(
sqlsmith.UnlikelyRandomNulls(), sqlsmith.DisableCrossJoins(),
sqlsmith.DisableIndexHints(), sqlsmith.DisableWith(),
sqlsmith.LowProbabilityWhereClauseWithJoinTables(),
// TODO(mgartner): Re-enable aggregate functions when we can guarantee
// they are deterministic.
sqlsmith.DisableAggregateFuncs(),
sqlsmith.SetComplexity(.3),
sqlsmith.SetScalarComplexity(.1),
)
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/smith/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var (
"DisableLimits": sqlsmith.DisableLimits(),
"AvoidConsts": sqlsmith.AvoidConsts(),
"DisableWindowFuncs": sqlsmith.DisableWindowFuncs(),
"DisableAggregateFuncs": sqlsmith.DisableAggregateFuncs(),
"OutputSort": sqlsmith.OutputSort(),
"UnlikelyConstantPredicate": sqlsmith.UnlikelyConstantPredicate(),
"FavorCommonData": sqlsmith.FavorCommonData(),
Expand Down
4 changes: 4 additions & 0 deletions pkg/internal/sqlsmith/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ func makeFunc(s *Smither, ctx Context, typ *types.T, refs colRefs) (tree.TypedEx
return nil, false
}

if fn.def.Class == tree.AggregateClass && s.disableAggregateFuncs {
return nil, false
}

var window *tree.WindowDef
// Use a window function if:
// - we chose an aggregate function, then 1/6 chance, but not if we're in a HAVING (noWindow == true)
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/sqlsmith/sqlsmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type Smither struct {
disableNondeterministicFns bool
disableLimits bool
disableWindowFuncs bool
disableAggregateFuncs bool
simpleDatums bool
avoidConsts bool
outputSort bool
Expand Down Expand Up @@ -378,6 +379,11 @@ var DisableWindowFuncs = simpleOption("disable window funcs", func(s *Smither) {
s.disableWindowFuncs = true
})

// DisableAggregateFuncs disables window functions.
var DisableAggregateFuncs = simpleOption("disable aggregate funcs", func(s *Smither) {
s.disableAggregateFuncs = true
})

// OutputSort adds a top-level ORDER BY on all columns.
var OutputSort = simpleOption("output sort", func(s *Smither) {
s.outputSort = true
Expand Down

0 comments on commit 8b546f8

Please sign in to comment.