Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Dec 5, 2023
1 parent d090b67 commit 5226e8c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions go/test/endtoend/vtgate/queries/query_fuzzing/query_gen2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,35 @@ limitations under the License.
package query_fuzzing

import (
"math/rand"

"vitess.io/vitess/go/vt/sqlparser"
)

// maruts is a query generator that generates random queries to be used in fuzzing
type maruts struct {
}
type (
// maruts is a query generator that generates random queries to be used in fuzzing
maruts struct {
cfg config
}

config struct {
r *rand.Rand
genConfig sqlparser.ExprGeneratorConfig
maxTables int
maxAggrs int
maxGBs int
schemaTables []tableT
}
)

func (m *maruts) randomQuery() sqlparser.SelectStatement {
expr := &sqlparser.AliasedExpr{Expr: sqlparser.NewIntLiteral("1")}
exprGen := sqlparser.NewGenerator(m.cfg.r, 2)
expr := exprGen.Expression(m.cfg.genConfig)

ae := &sqlparser.AliasedExpr{Expr: expr}
tableExpr := &sqlparser.AliasedTableExpr{Expr: sqlparser.NewTableName("dual")}
return &sqlparser.Select{
SelectExprs: sqlparser.SelectExprs{expr},
SelectExprs: sqlparser.SelectExprs{ae},
From: []sqlparser.TableExpr{tableExpr},
}
}
Expand Down

0 comments on commit 5226e8c

Please sign in to comment.