Documentation ¶
Index ¶
- Variables
- func IsConstant(compiled Compiled) bool
- type Arguments
- type ArithFunc
- type ArrayFunc
- type BitNotFunc
- type BitwiseFunc
- type CSVWriter
- func (w *CSVWriter) WriteFileHeader(table *Table) error
- func (w *CSVWriter) WriteRowGroupHeader(_ *Table) error
- func (w *CSVWriter) WriteRowGroupTrailer() error
- func (w *CSVWriter) WriteRowSeparator() error
- func (w *CSVWriter) WriteValue(value constant.Value) error
- func (w *CSVWriter) WriteValueHeader(_ template.Name) error
- func (w *CSVWriter) WriteValueSeparator() error
- type CaseValueWhen
- type CharLengthFunc
- type CoalesceFunc
- type CompareFunc
- type CompileContext
- func (ctx *CompileContext) CompileExpr(expr template.Expr) (Compiled, error)
- func (ctx *CompileContext) CompileRow(exprs []template.Expr) (Row, error)
- func (ctx *CompileContext) CompileTable(t *template.Table) (*Table, error)
- func (ctx *CompileContext) CompileTemplate(t *template.Template) (*Template, error)
- func (ctx *CompileContext) ParseTimeZone(tz string) (*time.Location, error)
- type Compiled
- type ConcatFunc
- type Constant
- type DecodeFunc
- type EncodeFunc
- type Encoding
- type Function
- type GenerateSeriesFunc
- type GetVariable
- type GreatestFunc
- type IsFunc
- type IsNotFunc
- type LastFunc
- type LeastFunc
- type LogicalAndFunc
- type LogicalOrFunc
- type NegFunc
- type NotFunc
- type OctetLengthFunc
- type OverlayFunc
- type PanicFunc
- type ParquetWriter
- func (w *ParquetWriter) WriteFileHeader(table *Table) error
- func (w *ParquetWriter) WriteRowGroupHeader(_ *Table) error
- func (w *ParquetWriter) WriteRowGroupTrailer() error
- func (w *ParquetWriter) WriteRowSeparator() error
- func (w *ParquetWriter) WriteValue(value constant.Value) error
- func (w *ParquetWriter) WriteValueHeader(_ template.Name) error
- func (w *ParquetWriter) WriteValueSeparator() error
- type RandBool
- type RandBoolFunc
- type RandFinite32
- type RandFinite64
- type RandFiniteF32Func
- type RandFiniteF64Func
- type RandLogNormal
- type RandLogNormalFunc
- type RandRangeFunc
- type RandRangeInclusiveFunc
- type RandRegex
- type RandRegexFunc
- type RandShuffle
- type RandShuffleFunc
- type RandU31Timestamp
- type RandU31TimestampFunc
- type RandUniformF64
- type RandUniformFunc
- type RandUniformI64
- type RandUniformInclusiveFunc
- type RandUniformU64
- type RandUuid
- type RandUuidFunc
- type RandZipf
- type RandZipfFunc
- type RawFunction
- type RoundFunc
- type Row
- type RowNum
- type SQLInsertSetWriter
- func (w *SQLInsertSetWriter) WriteFileHeader(table *Table) error
- func (w *SQLInsertSetWriter) WriteRowGroupHeader(_ *Table) error
- func (w *SQLInsertSetWriter) WriteRowGroupTrailer() error
- func (w *SQLInsertSetWriter) WriteRowSeparator() error
- func (w *SQLInsertSetWriter) WriteValue(value constant.Value) error
- func (w *SQLInsertSetWriter) WriteValueHeader(_ template.Name) error
- func (w *SQLInsertSetWriter) WriteValueSeparator() error
- type SQLWriter
- func (w *SQLWriter) WriteFileHeader(table *Table) error
- func (w *SQLWriter) WriteRowGroupHeader(_ *Table) error
- func (w *SQLWriter) WriteRowGroupTrailer() error
- func (w *SQLWriter) WriteRowSeparator() error
- func (w *SQLWriter) WriteValue(value constant.Value) error
- func (w *SQLWriter) WriteValueHeader(_ template.Name) error
- func (w *SQLWriter) WriteValueSeparator() error
- type SetVariable
- type State
- type SubRowNum
- type SubscriptFunc
- type SubstringFunc
- type Table
- type Template
- type TimestampFunc
- type TimestampWithTimeZoneFunc
- type When
- type Writer
Constants ¶
This section is empty.
Variables ¶
var BinaryFuncs = map[template.Op]Function{ template.OpLT: CompareFunc{LT: true}, template.OpLE: CompareFunc{LT: true, EQ: true}, template.OpEQ: CompareFunc{EQ: true}, template.OpNE: CompareFunc{LT: true, GT: true}, template.OpGT: CompareFunc{GT: true}, template.OpGE: CompareFunc{GT: true, EQ: true}, template.OpBitAnd: BitwiseFunc{Op: template.OpBitAnd}, template.OpBitOr: BitwiseFunc{Op: template.OpBitOr}, template.OpBitXor: BitwiseFunc{Op: template.OpBitXor}, template.OpAdd: ArithFunc{Op: constant.Add}, template.OpSub: ArithFunc{Op: constant.Sub}, template.OpMul: ArithFunc{Op: constant.Mul}, template.OpFloatDiv: ArithFunc{Op: constant.FloatDiv}, template.OpConcat: ConcatFunc{}, }
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 ¶
IsConstant returns true if the compiled expression is a constant.
Types ¶
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.
type ArrayFunc ¶
type ArrayFunc struct {
// contains filtered or unexported fields
}
ArrayFunc constructs a array.
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)
type BitwiseFunc ¶
BitwiseFunc implements the bitwise ('&', '|', '^') SQL functions.
func (BitwiseFunc) Compile ¶
func (b BitwiseFunc) Compile(_ *CompileContext, args Arguments) (Compiled, error)
type CSVWriter ¶
type CSVWriter struct {
// contains filtered or unexported fields
}
func (*CSVWriter) WriteFileHeader ¶
func (*CSVWriter) WriteRowGroupHeader ¶
func (*CSVWriter) WriteRowGroupTrailer ¶
func (*CSVWriter) WriteRowSeparator ¶
func (*CSVWriter) WriteValueSeparator ¶
type CaseValueWhen ¶
CaseValueWhen is a `CASE _ WHEN` expression.
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)
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)
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)
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)
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)
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)
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) Compile(_ *CompileContext, args Arguments) (Compiled, 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)
type IsNotFunc ¶
type IsNotFunc struct {
// contains filtered or unexported fields
}
IsNotFunc implements the 'IS NOT' SQL function.
type LastFunc ¶
type LastFunc struct{}
LastFunc is a function that returns the last value in a list of arguments.
type LeastFunc ¶
type LeastFunc struct {
// contains filtered or unexported fields
}
LeastFunc implements the 'least' SQL function.
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
}
type NotFunc ¶
type NotFunc struct {
// contains filtered or unexported fields
}
NotFunc implements the 'NOT' SQL function.
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)
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)
type PanicFunc ¶
type PanicFunc struct {
// contains filtered or unexported fields
}
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 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)
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)
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)
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)
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)
type RandRangeInclusiveFunc ¶
type RandRangeInclusiveFunc struct {
// contains filtered or unexported fields
}
RandRangeInclusiveFunc implements the 'rand.range_inclusive' SQL function.
func (RandRangeInclusiveFunc) Compile ¶
func (RandRangeInclusiveFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, 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)
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)
type RandU31TimestampFunc ¶
type RandU31TimestampFunc struct {
// contains filtered or unexported fields
}
RandU31TimestampFunc implements the 'rand.u31_timestamp' SQL function.
func (RandU31TimestampFunc) Compile ¶
func (RandU31TimestampFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, 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)
type RandUniformInclusiveFunc ¶
type RandUniformInclusiveFunc struct {
// contains filtered or unexported fields
}
RandUniformInclusiveFunc implements the 'rand.uniform_inclusive' SQL function.
func (RandUniformInclusiveFunc) Compile ¶
func (RandUniformInclusiveFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, 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)
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)
type RawFunction ¶
RawFunction is a function that has not been compiled.
type RoundFunc ¶
type RoundFunc struct {
// contains filtered or unexported fields
}
RoundFunc implements the 'round' SQL function.
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 (*SQLWriter) WriteRowGroupHeader ¶
func (*SQLWriter) WriteRowGroupTrailer ¶
func (*SQLWriter) WriteRowSeparator ¶
func (*SQLWriter) WriteValueSeparator ¶
type SetVariable ¶
SetVariable assigns a value to a local variable.
type State ¶
type State struct { RowNum int64 SubRowNum int64 Rng rand.Source64 CompileCtx *CompileContext }
State is the mutable state used during evaluation.
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)
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)
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)
type TimestampWithTimeZoneFunc ¶
type TimestampWithTimeZoneFunc struct {
// contains filtered or unexported fields
}
TimestampWithTimeZoneFunc implements the 'timestamp with time zone' SQL function.
func (TimestampWithTimeZoneFunc) Compile ¶
func (TimestampWithTimeZoneFunc) Compile(ctx *CompileContext, args Arguments) (Compiled, error)
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.