expr

package
v0.0.0-...-c0700b7 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2017 License: BSD-2-Clause-Views Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBuilder = &ExpressionBuilder{
	Expr: func(map[string]interface{}) (interface{}, error) { return true, nil },
}

DefaultBuilder returns true & OK because it is the default WHERE & HAVING

View Source
var FuncMap = map[string]interface{}{

	"char_length":  func(s string) int { return utf8.RuneCount([]byte(s)) },
	"lower":        strings.ToLower,
	"upper":        strings.ToUpper,
	"octet_length": func(s string) int { return len([]byte(s)) },
	"position":     stringFuncFind,
	"find":         stringFuncFind,
	"textpos":      stringFuncFind,
	"index":        stringFuncFind,
	"substr":       stringFuncSubstr,
	"substring":    stringFuncSubstr,

	"abs":   math.Abs,
	"pow":   math.Pow,
	"minOf": math.Min,
	"maxOf": math.Max,
	"floor": math.Floor,
	"ceil":  math.Ceil,
}

Functions

This section is empty.

Types

type AggAvg

type AggAvg struct {
	E
}

func (*AggAvg) Incr

func (a *AggAvg) Incr(row map[string]interface{}, vp interface{}) error

func (*AggAvg) Initial

func (a *AggAvg) Initial() interface{}

func (*AggAvg) Value

func (a *AggAvg) Value(vp interface{}) (res interface{})

type AggAvgData

type AggAvgData struct {
	V  float64
	Ct int
}

type AggCount

type AggCount struct{}

func (*AggCount) Incr

func (a *AggCount) Incr(row map[string]interface{}, vp interface{}) error

func (*AggCount) Initial

func (a *AggCount) Initial() interface{}

func (*AggCount) Value

func (a *AggCount) Value(vp interface{}) (res interface{})

type AggCountData

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

type AggCountDistinct

type AggCountDistinct struct{ E }

func (*AggCountDistinct) Incr

func (a *AggCountDistinct) Incr(row map[string]interface{}, vp interface{}) error

func (*AggCountDistinct) Initial

func (a *AggCountDistinct) Initial() interface{}

func (*AggCountDistinct) Value

func (a *AggCountDistinct) Value(vp interface{}) (res interface{})

type AggCountDistinctData

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

type AggFloatData

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

type AggGroup

type AggGroup struct {
	*ExpressionBuilder

	TokenRow map[string]interface{}
	// contains filtered or unexported fields
}

func (*AggGroup) ConsumeRow

func (g *AggGroup) ConsumeRow(row map[string]interface{}) error

ConsumeRow eats a row and runs aggregate incrementers on it

func (*AggGroup) RenderExpression

func (g *AggGroup) RenderExpression(E E) (interface{}, error)

RenderExpression will get a result. Even works with non-aggregate expressions

type AggMax

type AggMax struct {
	E
}

func (*AggMax) Incr

func (a *AggMax) Incr(row map[string]interface{}, vp interface{}) error

func (*AggMax) Initial

func (a *AggMax) Initial() interface{}

func (*AggMax) Value

func (a *AggMax) Value(vp interface{}) (res interface{})

type AggMin

type AggMin struct {
	E
}

func (*AggMin) Incr

func (a *AggMin) Incr(row map[string]interface{}, vp interface{}) error

func (*AggMin) Initial

func (a *AggMin) Initial() interface{}

func (*AggMin) Value

func (a *AggMin) Value(vp interface{}) (res interface{})

type AggProcessing

type AggProcessing interface {
	Value(interface{}) interface{}                  // Get final value & reset
	Incr(map[string]interface{}, interface{}) error // GroupBy iteration
	Initial() interface{}
}

type AggSum

type AggSum struct {
	E
}

func (*AggSum) Incr

func (a *AggSum) Incr(row map[string]interface{}, vp interface{}) error

func (*AggSum) Initial

func (a *AggSum) Initial() interface{}

func (*AggSum) Value

func (a *AggSum) Value(vp interface{}) (res interface{})

type E

type E func(map[string]interface{}) (interface{}, error)

E -xpression function

type ExpressionBuilder

type ExpressionBuilder struct {
	base.SrcTables
	AggProcessing *[]AggProcessing
	Expr          E // Expression storage relating to this builder
	Obj           map[string]interface{}
	SubqueryRunner
}

ExpressionBuilder builds expressions with regular functions

func (*ExpressionBuilder) AllowAggregates

func (e *ExpressionBuilder) AllowAggregates()

AllowAggregates Indicate if this builder should enable aggregate processing.

func (*ExpressionBuilder) Dup

Dup -licate an expressionbuilder that's correct (but you want agg)

func (*ExpressionBuilder) ExprToE

func (e *ExpressionBuilder) ExprToE(tree sqlparser.Expr) (E, error)

ExprToE converts a parsed expression into a runnable one.

func (*ExpressionBuilder) MakeAgg

func (e *ExpressionBuilder) MakeAgg(fe *sqlparser.FuncExpr, ag func(E) AggProcessing) (E, error)

Plan: SELECT & HAVING expressionbuilders should set e.AggProcessing = []expr.AggProcessing{} to allow aggregates. for everything GROUPBY touches, run: for new groupby: DEEP_COPY e.AggProcessing

for _, apCopy := range groupByThingy.AggProcessingCopies {
     err := apCopy.Incr(row)
     ...

Then delete the row (if not first). When input stops, per group: replace the e.AggProcessing and run expression

func (*ExpressionBuilder) MakeBool

func (e *ExpressionBuilder) MakeBool(tree sqlparser.BoolExpr) (E, error)

func (*ExpressionBuilder) MakeCompare

func (e *ExpressionBuilder) MakeCompare(tree *sqlparser.ComparisonExpr) (E, error)

MakeCompare compares all types

func (*ExpressionBuilder) MakeFunc

func (e *ExpressionBuilder) MakeFunc(fe *sqlparser.FuncExpr) (E, error)

func (*ExpressionBuilder) MakeSlice

func (e *ExpressionBuilder) MakeSlice(t []sqlparser.ValExpr) (E, error)

func (*ExpressionBuilder) MakeVal

func (e *ExpressionBuilder) MakeVal(tree sqlparser.ValExpr) (E, error)

MakeVal renders an SQL value into a function-consumable thing

func (*ExpressionBuilder) NewAggGroup

func (e *ExpressionBuilder) NewAggGroup() *AggGroup

NewAggGroup sets-up GroupBy to easily manage aggregate expressions

func (*ExpressionBuilder) Setup

func (e *ExpressionBuilder) Setup(
	t base.SrcTables, Obj map[string]interface{}, sqFunc SubqueryRunner) *ExpressionBuilder

func (*ExpressionBuilder) SubqueryToList

func (e *ExpressionBuilder) SubqueryToList(t *sqlparser.Subquery) (E, error)

type SubqueryRunner

type SubqueryRunner func(selStmt sqlparser.SelectStatement, src base.Obj, ctx context.Context) (chOut chan base.GetChanError, colCh chan []string)

Jump to

Keyboard shortcuts

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