testquery

package
v0.0.0-...-86e9f11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package testquery provides common functions used in query tests.

Index

Constants

View Source
const (
	FlagParallel    = 1 << iota // run in parallel
	FlagResymbolize             // resymbolize
	FlagShuffle                 // shuffle symbol table
	FlagSplit                   // use a split plan
)
View Source
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

func CanShuffleInput(q *expr.Query) bool

CanShuffleInput determines whether the inputs to the query can be shuffled

func CanShuffleSymtab

func CanShuffleSymtab(q *expr.Query) bool

CanShuffleSymtab determines whether symtab can be safely shuffled

func IonizeRow

func IonizeRow(b []byte, outst *ion.Symtab, symbolize func() bool) ([]ion.Datum, error)

IonizeRow ionizes the row in b, give outgoing symbol table and symbolize function

func NeedShuffleOutput

func NeedShuffleOutput(q *expr.Query) bool

NeedShuffleOutput determines whether the output need to be shuffled along with the input

func ReadBenchmark

func ReadBenchmark(root fs.FS, r io.Reader) (*expr.Query, *benchmarkSettings, []byte, error)

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

func ReadCase(r io.Reader) (qtc *Case, err error)

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

func ReadCaseFromFile(path string) (qtc *Case, err error)

func (*Case) Execute

func (q *Case) Execute(flags RunFlags) error

func (*Case) Shuffle

func (q *Case) Shuffle()

Shuffle shuffles if possible

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.

func (*Env) Geometry

func (e *Env) Geometry() *plan.Geometry

func (*Env) Index

func (e *Env) Index(t expr.Node) (plan.Index, error)

func (*Env) ListTables

func (e *Env) ListTables(db string) ([]string, error)

func (*Env) Run

func (e *Env) Run(dst vm.QuerySink, in *plan.Input, ep *plan.ExecParams) error

func (*Env) Stat

func (e *Env) Stat(t expr.Node, h *plan.Hints) (*plan.Input, error)

Stat implements plan.Env.Stat

type Input

type Input interface {
	Run(dst vm.QuerySink, blocks ints.Intervals, parallel int) error
	Size() int64
	Trailer() *blockfmt.Trailer
}

type RawInput

type RawInput []byte

func (RawInput) Run

func (b RawInput) Run(dst vm.QuerySink, _ ints.Intervals, parallel int) error

func (RawInput) Size

func (b RawInput) Size() int64

func (RawInput) Trailer

func (b RawInput) Trailer() *blockfmt.Trailer

type RunFlags

type RunFlags int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL