dbgen

package module
v0.0.0-...-13da7e0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 15 Imported by: 0

README

dbgen

This is a pure-go implementation of dbgen. It's still in development, and not ready for use.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenericFuncs = map[string]Function{
	"generate_series":        GenerateSeriesFunc{},
	"encode.hex":             EncodeFunc{Encoding: HexEncoding},
	"encode.base64":          EncodeFunc{Encoding: Base64Encoding},
	"decode.hex":             DecodeFunc{Encoding: HexEncoding},
	"decode.base64":          DecodeFunc{Encoding: Base64Encoding},
	"debug.panic":            PanicFunc{},
	"least":                  LeastFunc{},
	"greatest":               GreatestFunc{},
	"round":                  RoundFunc{},
	"div":                    ArithFunc{Op: constant.Div},
	"mod":                    ArithFunc{Op: constant.Mod},
	"coalesce":               CoalesceFunc{},
	"rand.range":             RandRangeFunc{},
	"rand.range_inclusive":   RandRangeInclusiveFunc{},
	"rand.uniform":           RandUniformFunc{},
	"rand.uniform_inclusive": RandUniformInclusiveFunc{},
	"rand.zipf":              RandZipfFunc{},
	"rand.log_normal":        RandLogNormalFunc{},
	"rand.bool":              RandBoolFunc{},
	"rand.finite_f32":        RandFiniteF32Func{},
	"rand.finite_f64":        RandFiniteF64Func{},
	"rand.u31_timestamp":     RandU31TimestampFunc{},
	"rand.uuid":              RandUuidFunc{},
	"rand.regex":             RandRegexFunc{},
	"rand.shuffle":           RandShuffleFunc{},
	"char_length":            CharLengthFunc{},
	"octet_length":           OctetLengthFunc{},
}

Functions

func IsConstant

func IsConstant(compiled Compiled) bool

IsConstant returns true if the compiled expression is a constant.

Types

type Arguments

type Arguments []constant.Value

Arguments is a list of arguments to a function.

type ArithFunc

type ArithFunc struct {
	Op func(constant.Value, constant.Value) (constant.Value, error)
	// contains filtered or unexported fields
}

ArithFunc implements the arithmetic (`+`, `-`, `*`, `/`, div, mod) SQL functions.

func (ArithFunc) Compile

func (a ArithFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (ArithFunc) NumArgs

func (ArithFunc) NumArgs() int

type ArrayFunc

type ArrayFunc struct {
	// contains filtered or unexported fields
}

ArrayFunc constructs a array.

func (ArrayFunc) Compile

func (ArrayFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (ArrayFunc) NumArgs

func (ArrayFunc) NumArgs() int

type BitNotFunc

type BitNotFunc struct {
	// contains filtered or unexported fields
}

BitNotFunc implements the '~' SQL function.

func (BitNotFunc) Compile

func (BitNotFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (BitNotFunc) NumArgs

func (BitNotFunc) NumArgs() int

type BitwiseFunc

type BitwiseFunc struct {
	Op template.Op
	// contains filtered or unexported fields
}

BitwiseFunc implements the bitwise ('&', '|', '^') SQL functions.

func (BitwiseFunc) Compile

func (b BitwiseFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (BitwiseFunc) NumArgs

func (BitwiseFunc) NumArgs() int

type CSVWriter

type CSVWriter struct {
	// contains filtered or unexported fields
}

func (*CSVWriter) WriteFileHeader

func (w *CSVWriter) WriteFileHeader(table *Table) error

func (*CSVWriter) WriteRowGroupHeader

func (w *CSVWriter) WriteRowGroupHeader(_ *Table) error

func (*CSVWriter) WriteRowGroupTrailer

func (w *CSVWriter) WriteRowGroupTrailer() error

func (*CSVWriter) WriteRowSeparator

func (w *CSVWriter) WriteRowSeparator() error

func (*CSVWriter) WriteValue

func (w *CSVWriter) WriteValue(value constant.Value) error

func (*CSVWriter) WriteValueHeader

func (w *CSVWriter) WriteValueHeader(_ template.Name) error

func (*CSVWriter) WriteValueSeparator

func (w *CSVWriter) WriteValueSeparator() error

type CaseValueWhen

type CaseValueWhen struct {
	Value Compiled
	Whens []*When
	Else  Compiled
}

CaseValueWhen is a `CASE _ WHEN` expression.

func (*CaseValueWhen) Eval

func (c *CaseValueWhen) Eval(_ *State) (constant.Value, error)

type CharLengthFunc

type CharLengthFunc struct {
	// contains filtered or unexported fields
}

CharLengthFunc implements the 'char_length' SQL function.

func (CharLengthFunc) Compile

func (CharLengthFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (CharLengthFunc) NumArgs

func (CharLengthFunc) NumArgs() int

type CoalesceFunc

type CoalesceFunc struct {
	// contains filtered or unexported fields
}

CoalesceFunc implements the 'coalesce' SQL function.

func (CoalesceFunc) Compile

func (CoalesceFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (CoalesceFunc) NumArgs

func (CoalesceFunc) NumArgs() int

type CompareFunc

type CompareFunc struct {

	/// Whether a less-than result is considered TRUE.
	LT bool
	/// Whether an equals result is considered TRUE.
	EQ bool
	/// Whether a greater-than result is considered TRUE.
	GT bool
	// contains filtered or unexported fields
}

CompareFunc implements the value comparison (`<`, `=`, `>`, `<=`, `<>`, `>=`) SQL functions.

func (CompareFunc) Compile

func (c CompareFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (CompareFunc) NumArgs

func (CompareFunc) NumArgs() int

type CompileContext

type CompileContext struct {
	// The time zone used to interpret strings into timestamps.
	TimeZone *time.Location
	// The current timestamp in UTC.
	CurrentTimestamp time.Time
	// LoadLocation is the function used to load the Location with the given name.
	LoadLocation func(name string) (*time.Location, error)
	// The global variables.
	Variables []lo.Tuple2[string, constant.Value]
	// contains filtered or unexported fields
}

CompileContext is the environment information shared by all compilations.

func NewCompileContext

func NewCompileContext() *CompileContext

func (*CompileContext) CompileExpr

func (ctx *CompileContext) CompileExpr(expr template.Expr) (Compiled, error)

func (*CompileContext) CompileRow

func (ctx *CompileContext) CompileRow(exprs []template.Expr) (Row, error)

func (*CompileContext) CompileTable

func (ctx *CompileContext) CompileTable(t *template.Table) (*Table, error)

func (*CompileContext) CompileTemplate

func (ctx *CompileContext) CompileTemplate(t *template.Template) (*Template, error)

func (*CompileContext) ParseTimeZone

func (ctx *CompileContext) ParseTimeZone(tz string) (*time.Location, error)

type Compiled

type Compiled interface {
	// Eval evaluates a compiled expression and updates the state. Returns the evaluated value.
	Eval(state *State) (constant.Value, error)
}

Compiled is a compiled expression.

type ConcatFunc

type ConcatFunc struct {
	// contains filtered or unexported fields
}

ConcatFunc implements the '||' SQL function.

func (ConcatFunc) Compile

func (ConcatFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (ConcatFunc) NumArgs

func (ConcatFunc) NumArgs() int

type Constant

type Constant struct{ Value constant.Value }

Constant is a evaluated constant.

func (*Constant) Eval

func (c *Constant) Eval(_ *State) (constant.Value, error)

type DecodeFunc

type DecodeFunc struct {
	Encoding Encoding
	// contains filtered or unexported fields
}

DecodeFunc implements the `decode.*` SQL function.

func (DecodeFunc) Compile

func (dec DecodeFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (DecodeFunc) NumArgs

func (DecodeFunc) NumArgs() int

type EncodeFunc

type EncodeFunc struct {
	Encoding Encoding
	// contains filtered or unexported fields
}

EncodeFunc implements the `encode.*` SQL function.

func (EncodeFunc) Compile

func (enc EncodeFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (EncodeFunc) NumArgs

func (EncodeFunc) NumArgs() int

type Encoding

type Encoding interface {
	// Encode encodes src into EncodedLen(len(src)) bytes of dst.
	Encode(dst, src []byte)
	// EncodedLen returns the length of an encoding of n source bytes.
	EncodedLen(n int) int
	// Decode decodes src into DecodedLen(len(src)) bytes,
	// returning the actual number of bytes written to dst.
	Decode(dst, src []byte) (n int, err error)
	// DecodedLen returns the maximum length in bytes of the decoded data
	// corresponding to n bytes of encoded data.
	DecodedLen(n int) int
}

Encoding is an interface for encoding and decoding byte slices.

var (
	HexEncoding    Encoding = hexEncoding{}
	Base64Encoding Encoding = base64.StdEncoding
)

type Function

type Function interface {
	// NumArgs returns the number of arguments the function accepts.
	// If the function accepts a variable number of arguments, it returns -1.
	NumArgs() int
	// Compile compiles or evaluates the function.
	Compile(ctx *CompileContext, args Arguments) (Compiled, error)
}

Function is a function that can be compiled.

type GenerateSeriesFunc

type GenerateSeriesFunc struct {
	// contains filtered or unexported fields
}

GenerateSeriesFunc implements the `generate_series` SQL function.

func (GenerateSeriesFunc) Compile

func (GenerateSeriesFunc) NumArgs

func (GenerateSeriesFunc) NumArgs() int

type GetVariable

type GetVariable struct{ Index int }

GetVariable is a local variable reference.

func (*GetVariable) Eval

func (g *GetVariable) Eval(state *State) (constant.Value, error)

type GreatestFunc

type GreatestFunc struct {
	// contains filtered or unexported fields
}

GreatestFunc implements the 'greatest' SQL function.

func (GreatestFunc) Compile

func (GreatestFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (GreatestFunc) NumArgs

func (GreatestFunc) NumArgs() int

type IsFunc

type IsFunc struct{}

IsFunc implements the 'IS' SQL function.

func (IsFunc) Compile

func (IsFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

type IsNotFunc

type IsNotFunc struct {
	// contains filtered or unexported fields
}

IsNotFunc implements the 'IS NOT' SQL function.

func (IsNotFunc) Compile

func (IsNotFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (IsNotFunc) NumArgs

func (IsNotFunc) NumArgs() int

type LastFunc

type LastFunc struct{}

LastFunc is a function that returns the last value in a list of arguments.

func (LastFunc) Compile

func (LastFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

type LeastFunc

type LeastFunc struct {
	// contains filtered or unexported fields
}

LeastFunc implements the 'least' SQL function.

func (LeastFunc) Compile

func (LeastFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (LeastFunc) NumArgs

func (LeastFunc) NumArgs() int

type LogicalAndFunc

type LogicalAndFunc struct{}

LogicalAndFunc implements the 'AND' SQL function.

func (LogicalAndFunc) Compile

func (LogicalAndFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

type LogicalOrFunc

type LogicalOrFunc struct{}

LogicalOrFunc implements the 'OR' SQL function.

func (LogicalOrFunc) Compile

func (LogicalOrFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

type NegFunc

type NegFunc struct {
	// contains filtered or unexported fields
}

func (NegFunc) Compile

func (NegFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (NegFunc) NumArgs

func (NegFunc) NumArgs() int

type NotFunc

type NotFunc struct {
	// contains filtered or unexported fields
}

NotFunc implements the 'NOT' SQL function.

func (NotFunc) Compile

func (NotFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (NotFunc) NumArgs

func (NotFunc) NumArgs() int

type OctetLengthFunc

type OctetLengthFunc struct {
	// contains filtered or unexported fields
}

OctetLengthFunc implements the 'octet_length' SQL function.

func (OctetLengthFunc) Compile

func (OctetLengthFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (OctetLengthFunc) NumArgs

func (OctetLengthFunc) NumArgs() int

type OverlayFunc

type OverlayFunc struct {
	Unit template.StringUnit
	// contains filtered or unexported fields
}

OverlayFunc implements the 'overlay' SQL function.

func (OverlayFunc) Compile

func (OverlayFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (OverlayFunc) NumArgs

func (OverlayFunc) NumArgs() int

type PanicFunc

type PanicFunc struct {
	// contains filtered or unexported fields
}

func (PanicFunc) Compile

func (PanicFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (PanicFunc) NumArgs

func (PanicFunc) NumArgs() int

type ParquetWriter

type ParquetWriter struct {
	// contains filtered or unexported fields
}

func (*ParquetWriter) WriteFileHeader

func (w *ParquetWriter) WriteFileHeader(table *Table) error

func (*ParquetWriter) WriteRowGroupHeader

func (w *ParquetWriter) WriteRowGroupHeader(_ *Table) error

func (*ParquetWriter) WriteRowGroupTrailer

func (w *ParquetWriter) WriteRowGroupTrailer() error

func (*ParquetWriter) WriteRowSeparator

func (w *ParquetWriter) WriteRowSeparator() error

func (*ParquetWriter) WriteValue

func (w *ParquetWriter) WriteValue(value constant.Value) error

func (*ParquetWriter) WriteValueHeader

func (w *ParquetWriter) WriteValueHeader(_ template.Name) error

func (*ParquetWriter) WriteValueSeparator

func (w *ParquetWriter) WriteValueSeparator() error

type RandBool

type RandBool struct{}

Compiled expression types.

func (*RandBool) Eval

func (*RandBool) Eval(state *State) (constant.Value, error)

type RandBoolFunc

type RandBoolFunc struct {
	// contains filtered or unexported fields
}

RandBoolFunc implements the 'rand.bool' SQL function.

func (RandBoolFunc) Compile

func (RandBoolFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandBoolFunc) NumArgs

func (RandBoolFunc) NumArgs() int

type RandFinite32

type RandFinite32 struct{}

Compiled expression types.

func (*RandFinite32) Eval

func (*RandFinite32) Eval(state *State) (constant.Value, error)

type RandFinite64

type RandFinite64 struct{}

Compiled expression types.

func (*RandFinite64) Eval

func (*RandFinite64) Eval(state *State) (constant.Value, error)

type RandFiniteF32Func

type RandFiniteF32Func struct {
	// contains filtered or unexported fields
}

RandFiniteF32Func implements the 'rand.finite_f32' SQL function.

func (RandFiniteF32Func) Compile

func (RandFiniteF32Func) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandFiniteF32Func) NumArgs

func (RandFiniteF32Func) NumArgs() int

type RandFiniteF64Func

type RandFiniteF64Func struct {
	// contains filtered or unexported fields
}

RandFiniteF64Func implements the 'rand.finite_f64' SQL function.

func (RandFiniteF64Func) Compile

func (RandFiniteF64Func) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandFiniteF64Func) NumArgs

func (RandFiniteF64Func) NumArgs() int

type RandLogNormal

type RandLogNormal struct{}

Compiled expression types.

func (*RandLogNormal) Eval

func (*RandLogNormal) Eval(state *State) (constant.Value, error)

type RandLogNormalFunc

type RandLogNormalFunc struct {
	// contains filtered or unexported fields
}

RandLogNormalFunc implements the 'rand.log_normal' SQL function.

func (RandLogNormalFunc) Compile

func (RandLogNormalFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandLogNormalFunc) NumArgs

func (RandLogNormalFunc) NumArgs() int

type RandRangeFunc

type RandRangeFunc struct {
	// contains filtered or unexported fields
}

RandRangeFunc implements the 'rand.range' SQL function.

func (RandRangeFunc) Compile

func (RandRangeFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandRangeFunc) NumArgs

func (RandRangeFunc) NumArgs() int

type RandRangeInclusiveFunc

type RandRangeInclusiveFunc struct {
	// contains filtered or unexported fields
}

RandRangeInclusiveFunc implements the 'rand.range_inclusive' SQL function.

func (RandRangeInclusiveFunc) Compile

func (RandRangeInclusiveFunc) NumArgs

func (RandRangeInclusiveFunc) NumArgs() int

type RandRegex

type RandRegex struct {
	Regex *regexp.Regexp
}

RandRegex is a regex-based random string.

func (*RandRegex) Eval

func (r *RandRegex) Eval(state *State) (constant.Value, error)

type RandRegexFunc

type RandRegexFunc struct {
	// contains filtered or unexported fields
}

RandRegexFunc implements the 'rand.regex' SQL function.

func (RandRegexFunc) Compile

func (RandRegexFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandRegexFunc) NumArgs

func (RandRegexFunc) NumArgs() int

type RandShuffle

type RandShuffle struct{}

Compiled expression types.

func (*RandShuffle) Eval

func (*RandShuffle) Eval(state *State) (constant.Value, error)

type RandShuffleFunc

type RandShuffleFunc struct {
	// contains filtered or unexported fields
}

RandShuffleFunc implements the 'rand.shuffle' SQL function.

func (RandShuffleFunc) Compile

func (RandShuffleFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandShuffleFunc) NumArgs

func (RandShuffleFunc) NumArgs() int

type RandU31Timestamp

type RandU31Timestamp struct{}

Compiled expression types.

func (*RandU31Timestamp) Eval

func (*RandU31Timestamp) Eval(state *State) (constant.Value, error)

type RandU31TimestampFunc

type RandU31TimestampFunc struct {
	// contains filtered or unexported fields
}

RandU31TimestampFunc implements the 'rand.u31_timestamp' SQL function.

func (RandU31TimestampFunc) Compile

func (RandU31TimestampFunc) NumArgs

func (RandU31TimestampFunc) NumArgs() int

type RandUniformF64

type RandUniformF64 struct{}

Compiled expression types.

func (*RandUniformF64) Eval

func (*RandUniformF64) Eval(state *State) (constant.Value, error)

type RandUniformFunc

type RandUniformFunc struct {
	// contains filtered or unexported fields
}

RandUniformFunc implements the 'rand.uniform' SQL function.

func (RandUniformFunc) Compile

func (RandUniformFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandUniformFunc) NumArgs

func (RandUniformFunc) NumArgs() int

type RandUniformI64

type RandUniformI64 struct{}

Compiled expression types.

func (*RandUniformI64) Eval

func (*RandUniformI64) Eval(state *State) (constant.Value, error)

type RandUniformInclusiveFunc

type RandUniformInclusiveFunc struct {
	// contains filtered or unexported fields
}

RandUniformInclusiveFunc implements the 'rand.uniform_inclusive' SQL function.

func (RandUniformInclusiveFunc) Compile

func (RandUniformInclusiveFunc) NumArgs

func (RandUniformInclusiveFunc) NumArgs() int

type RandUniformU64

type RandUniformU64 struct{}

Compiled expression types.

func (*RandUniformU64) Eval

func (*RandUniformU64) Eval(state *State) (constant.Value, error)

type RandUuid

type RandUuid struct{}

Compiled expression types.

func (*RandUuid) Eval

func (*RandUuid) Eval(state *State) (constant.Value, error)

type RandUuidFunc

type RandUuidFunc struct {
	// contains filtered or unexported fields
}

RandUuidFunc implements the 'rand.uuid' SQL function.

func (RandUuidFunc) Compile

func (RandUuidFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandUuidFunc) NumArgs

func (RandUuidFunc) NumArgs() int

type RandZipf

type RandZipf struct{}

Compiled expression types.

func (*RandZipf) Eval

func (*RandZipf) Eval(state *State) (constant.Value, error)

type RandZipfFunc

type RandZipfFunc struct {
	// contains filtered or unexported fields
}

RandZipfFunc implements the 'rand.zipf' SQL function.

func (RandZipfFunc) Compile

func (RandZipfFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RandZipfFunc) NumArgs

func (RandZipfFunc) NumArgs() int

type RawFunction

type RawFunction struct {
	Fn   Function
	Args []Compiled
}

RawFunction is a function that has not been compiled.

func (*RawFunction) Eval

func (r *RawFunction) Eval(state *State) (constant.Value, error)

type RoundFunc

type RoundFunc struct {
	// contains filtered or unexported fields
}

RoundFunc implements the 'round' SQL function.

func (RoundFunc) Compile

func (RoundFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (RoundFunc) NumArgs

func (RoundFunc) NumArgs() int

type Row

type Row []Compiled

Row represents a row of compiled values.

func (Row) Eval

func (r Row) Eval(state *State) ([]constant.Value, error)

type RowNum

type RowNum struct{}

RowNum is the row number.

func (*RowNum) Eval

func (*RowNum) Eval(state *State) (constant.Value, error)

type SQLInsertSetWriter

type SQLInsertSetWriter struct {
	// contains filtered or unexported fields
}

func (*SQLInsertSetWriter) WriteFileHeader

func (w *SQLInsertSetWriter) WriteFileHeader(table *Table) error

func (*SQLInsertSetWriter) WriteRowGroupHeader

func (w *SQLInsertSetWriter) WriteRowGroupHeader(_ *Table) error

func (*SQLInsertSetWriter) WriteRowGroupTrailer

func (w *SQLInsertSetWriter) WriteRowGroupTrailer() error

func (*SQLInsertSetWriter) WriteRowSeparator

func (w *SQLInsertSetWriter) WriteRowSeparator() error

func (*SQLInsertSetWriter) WriteValue

func (w *SQLInsertSetWriter) WriteValue(value constant.Value) error

func (*SQLInsertSetWriter) WriteValueHeader

func (w *SQLInsertSetWriter) WriteValueHeader(_ template.Name) error

func (*SQLInsertSetWriter) WriteValueSeparator

func (w *SQLInsertSetWriter) WriteValueSeparator() error

type SQLWriter

type SQLWriter struct {
	// contains filtered or unexported fields
}

func (*SQLWriter) WriteFileHeader

func (w *SQLWriter) WriteFileHeader(table *Table) error

func (*SQLWriter) WriteRowGroupHeader

func (w *SQLWriter) WriteRowGroupHeader(_ *Table) error

func (*SQLWriter) WriteRowGroupTrailer

func (w *SQLWriter) WriteRowGroupTrailer() error

func (*SQLWriter) WriteRowSeparator

func (w *SQLWriter) WriteRowSeparator() error

func (*SQLWriter) WriteValue

func (w *SQLWriter) WriteValue(value constant.Value) error

func (*SQLWriter) WriteValueHeader

func (w *SQLWriter) WriteValueHeader(_ template.Name) error

func (*SQLWriter) WriteValueSeparator

func (w *SQLWriter) WriteValueSeparator() error

type SetVariable

type SetVariable struct {
	Index int
	Value Compiled
}

SetVariable assigns a value to a local variable.

func (*SetVariable) Eval

func (s *SetVariable) Eval(state *State) (constant.Value, error)

type State

type State struct {
	RowNum     int64
	SubRowNum  int64
	Rng        rand.Source64
	CompileCtx *CompileContext
}

State is the mutable state used during evaluation.

type SubRowNum

type SubRowNum struct{}

SubRowNum is the derived row number.

func (*SubRowNum) Eval

func (*SubRowNum) Eval(state *State) (constant.Value, error)

type SubscriptFunc

type SubscriptFunc struct {
	// contains filtered or unexported fields
}

SubscriptFunc subscript a array.

func (SubscriptFunc) Compile

func (SubscriptFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)

func (SubscriptFunc) NumArgs

func (SubscriptFunc) NumArgs() int

type SubstringFunc

type SubstringFunc struct {
	Unit template.StringUnit
	// contains filtered or unexported fields
}

SubstringFunc implements the 'substring' SQL function.

func (SubstringFunc) Compile

func (SubstringFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (SubstringFunc) NumArgs

func (SubstringFunc) NumArgs() int

type Table

type Table struct {
	Name    *template.QName
	Content string
	Columns []template.Name
	Row     Row
	Derived []lo.Tuple2[int, Compiled]
}

type Template

type Template struct {
	GlobalExprs Row
	Tables      []*Table
}

type TimestampFunc

type TimestampFunc struct {
	// contains filtered or unexported fields
}

TimestampFunc implements the 'timestamp' SQL function.

func (TimestampFunc) Compile

func (TimestampFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)

func (TimestampFunc) NumArgs

func (TimestampFunc) NumArgs() int

type TimestampWithTimeZoneFunc

type TimestampWithTimeZoneFunc struct {
	// contains filtered or unexported fields
}

TimestampWithTimeZoneFunc implements the 'timestamp with time zone' SQL function.

func (TimestampWithTimeZoneFunc) Compile

func (TimestampWithTimeZoneFunc) NumArgs

func (TimestampWithTimeZoneFunc) NumArgs() int

type When

type When struct {
	Cond Compiled
	Then Compiled
}

type Writer

type Writer interface {
	// WriteValue writes a single value.
	WriteValue(value constant.Value) error
	// WriteFileHeader writes the content at the beginning of the file.
	WriteFileHeader(table *Table) error
	// WriteRowGroupHeader writes the content before a row group.
	WriteRowGroupHeader(table *Table) error
	// WriteValueHeader writes the column name before a value.
	WriteValueHeader(column template.Name) error
	// WriteValueSeparator writes the separator between the every value.
	WriteValueSeparator() error
	// WriteRowSeparator writes the separator between the every row.
	WriteRowSeparator() error
	// WriteRowGroupTrailer writes the content after a row group.
	WriteRowGroupTrailer() error
}

Writer specifies how to write rows to a file.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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