Documentation ¶
Overview ¶
Package testquery provides common functions used in query tests.
Index ¶
- Constants
- func CanShuffleInput(q *expr.Query) bool
- func CanShuffleSymtab(q *expr.Query) bool
- func IonizeRow(b []byte, outst *ion.Symtab, symbolize func() bool) ([]ion.Datum, error)
- func NeedShuffleOutput(q *expr.Query) bool
- func ReadBenchmark(root fs.FS, r io.Reader) (*expr.Query, *benchmarkSettings, []byte, error)
- type Case
- type Env
- type Input
- type RawInput
- type RunFlags
Constants ¶
const ( FlagParallel = 1 << iota // run in parallel FlagResymbolize // resymbolize FlagShuffle // shuffle symbol table FlagSplit // use a split plan )
const MaxAutoPartitions = 100
MaxAutoPartitions is the maximum number of distinct partitions produced when attempting to satisfy requests from the query planner to partition the input table(s). This limit exists to keep unit tests from becoming too slow due to the expense of dynamically partitioning the data on-demand.
Variables ¶
This section is empty.
Functions ¶
func CanShuffleInput ¶
CanShuffleInput determines whether the inputs to the query can be shuffled
func CanShuffleSymtab ¶
CanShuffleSymtab determines whether symtab can be safely shuffled
func NeedShuffleOutput ¶
NeedShuffleOutput determines whether the output need to be shuffled along with the input
func ReadBenchmark ¶
ReadBenchmark reads a benchmark specification.
Benchmark may contain either SQL query (text) and sample input (ND-JSON) separated with '---'.
Alternatively, it may contain only an SQL query. But then the FROM part has to be a string which is treated as a filename and this file is read into the input (as NDJSON) relative to the given [root].
Types ¶
type Case ¶
type Case struct { // QueryStr is the raw query string. QueryStr []byte // Query is the parsed query. Query *expr.Query // SymbolTable is the symbol table used // for the input datums. SymbolTable *ion.Symtab // Input is the raw input data for the query, // grouped by table input. If [len(Input)] is 1, // then datums in [Input[0]] correspond to the table [input]. // Otherwise, [Input[0]] corresponds to [input0], // [Input[1]] corresponds to [input1], and so forth. Input [][]ion.Datum // Output is the expected output of the query when // it is run on the provided input(s). Output []ion.Datum // Tags is the set of tags from the testcase file. // See also [tests.CaseSpec.Tags]. Tags map[string]string }
Case is a test case.
func ReadCase ¶
ReadCase reads a testcase file. The testcase must be in tests.CaseSpec format. See tests.ReadSpec.
Each test case must consist of at least 3 sections. The first section should be a SQL query, and the second and third sections should be sequences of JSON records. The second section is interpreted as table data and mapped to the table [input], and the third section is interpreted as output. If more than 3 sections are present, the middle sections are interpreted as inputs and mapped to the tables [input0], [input1], and so on.
func ReadCaseFromFile ¶
type Env ¶
type Env struct { // In is the set of tables in the environment. // If [len(In) == 1], then `In[0]` is the table [input]. // Otherwise tables [input0], [input1], etc. correspond // to [In[0]], [In[1]], and so forth. In []Input // contains filtered or unexported fields }
Env is an implementation of plan.Env uses for evaluating test cases.