function

package
v0.0.0-...-e79d762 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults = sql.Functions{
	"count": sql.Function1(func(e sql.Expression) sql.Expression {
		return aggregation.NewCount(e)
	}),
	"min": sql.Function1(func(e sql.Expression) sql.Expression {
		return aggregation.NewMin(e)
	}),
	"max": sql.Function1(func(e sql.Expression) sql.Expression {
		return aggregation.NewMax(e)
	}),
	"avg": sql.Function1(func(e sql.Expression) sql.Expression {
		return aggregation.NewAvg(e)
	}),
	"sum": sql.Function1(func(e sql.Expression) sql.Expression {
		return aggregation.NewSum(e)
	}),
	"is_binary":    sql.Function1(NewIsBinary),
	"substring":    sql.FunctionN(NewSubstring),
	"year":         sql.Function1(NewYear),
	"month":        sql.Function1(NewMonth),
	"day":          sql.Function1(NewDay),
	"hour":         sql.Function1(NewHour),
	"minute":       sql.Function1(NewMinute),
	"second":       sql.Function1(NewSecond),
	"dayofyear":    sql.Function1(NewDayOfYear),
	"array_length": sql.Function1(NewArrayLength),
	"split":        sql.Function2(NewSplit),
}

Defaults is the function map with all the default functions.

View Source
var ErrConcatArrayWithOthers = errors.NewKind("can't concat a string array with any other elements")

ErrConcatArrayWithOthers is returned when there are more than 1 argument in concat and any of them is an array.

Functions

func NewArrayLength

func NewArrayLength(array sql.Expression) sql.Expression

NewArrayLength creates a new ArrayLength UDF.

func NewConcat

func NewConcat(args ...sql.Expression) (sql.Expression, error)

NewConcat creates a new Concat UDF.

func NewDay

func NewDay(date sql.Expression) sql.Expression

NewDay creates a new Day UDF.

func NewDayOfYear

func NewDayOfYear(date sql.Expression) sql.Expression

NewDayOfYear creates a new DayOfYear UDF.

func NewHour

func NewHour(date sql.Expression) sql.Expression

NewHour creates a new Hour UDF.

func NewIsBinary

func NewIsBinary(e sql.Expression) sql.Expression

NewIsBinary creates a new IsBinary expression.

func NewMinute

func NewMinute(date sql.Expression) sql.Expression

NewMinute creates a new Minute UDF.

func NewMonth

func NewMonth(date sql.Expression) sql.Expression

NewMonth creates a new Month UDF.

func NewSecond

func NewSecond(date sql.Expression) sql.Expression

NewSecond creates a new Second UDF.

func NewSplit

func NewSplit(str, delimiter sql.Expression) sql.Expression

NewSplit creates a new Split UDF.

func NewSubstring

func NewSubstring(args ...sql.Expression) (sql.Expression, error)

NewSubstring creates a new substring UDF.

func NewYear

func NewYear(date sql.Expression) sql.Expression

NewYear creates a new Year UDF.

Types

type ArrayLength

type ArrayLength struct {
	expression.UnaryExpression
}

ArrayLength returns the length of an array.

func (*ArrayLength) Eval

func (f *ArrayLength) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*ArrayLength) String

func (f *ArrayLength) String() string

func (*ArrayLength) TransformUp

func (f *ArrayLength) TransformUp(fn sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*ArrayLength) Type

func (*ArrayLength) Type() sql.Type

Type implements the Expression interface.

type Concat

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

Concat joins several strings together.

func (*Concat) Children

func (f *Concat) Children() []sql.Expression

Children implements the Expression interface.

func (*Concat) Eval

func (f *Concat) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Concat) IsNullable

func (f *Concat) IsNullable() bool

IsNullable implements the Expression interface.

func (*Concat) Resolved

func (f *Concat) Resolved() bool

Resolved implements the Expression interface.

func (*Concat) String

func (f *Concat) String() string

func (*Concat) TransformUp

func (f *Concat) TransformUp(fn sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Concat) Type

func (f *Concat) Type() sql.Type

Type implements the Expression interface.

type Day

type Day struct {
	expression.UnaryExpression
}

Day is a function that returns the day of a date.

func (*Day) Eval

func (d *Day) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Day) String

func (d *Day) String() string

func (*Day) TransformUp

func (d *Day) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Day) Type

func (d *Day) Type() sql.Type

Type implements the Expression interface.

type DayOfYear

type DayOfYear struct {
	expression.UnaryExpression
}

DayOfYear is a function that returns the day of the year from a date.

func (*DayOfYear) Eval

func (d *DayOfYear) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*DayOfYear) String

func (d *DayOfYear) String() string

func (*DayOfYear) TransformUp

func (d *DayOfYear) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*DayOfYear) Type

func (d *DayOfYear) Type() sql.Type

Type implements the Expression interface.

type Hour

type Hour struct {
	expression.UnaryExpression
}

Hour is a function that returns the hour of a date.

func (*Hour) Eval

func (h *Hour) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Hour) String

func (h *Hour) String() string

func (*Hour) TransformUp

func (h *Hour) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Hour) Type

func (h *Hour) Type() sql.Type

Type implements the Expression interface.

type IsBinary

type IsBinary struct {
	expression.UnaryExpression
}

IsBinary is a function that returns whether a blob is binary or not.

func (*IsBinary) Eval

func (ib *IsBinary) Eval(
	ctx *sql.Context,
	row sql.Row,
) (interface{}, error)

Eval implements the Expression interface.

func (*IsBinary) String

func (ib *IsBinary) String() string

func (*IsBinary) TransformUp

func (ib *IsBinary) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*IsBinary) Type

func (ib *IsBinary) Type() sql.Type

Type implements the Expression interface.

type Minute

type Minute struct {
	expression.UnaryExpression
}

Minute is a function that returns the minute of a date.

func (*Minute) Eval

func (m *Minute) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Minute) String

func (m *Minute) String() string

func (*Minute) TransformUp

func (m *Minute) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Minute) Type

func (m *Minute) Type() sql.Type

Type implements the Expression interface.

type Month

type Month struct {
	expression.UnaryExpression
}

Month is a function that returns the month of a date.

func (*Month) Eval

func (m *Month) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Month) String

func (m *Month) String() string

func (*Month) TransformUp

func (m *Month) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Month) Type

func (m *Month) Type() sql.Type

Type implements the Expression interface.

type Second

type Second struct {
	expression.UnaryExpression
}

Second is a function that returns the second of a date.

func (*Second) Eval

func (s *Second) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Second) String

func (s *Second) String() string

func (*Second) TransformUp

func (s *Second) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Second) Type

func (s *Second) Type() sql.Type

Type implements the Expression interface.

type Split

type Split struct {
	expression.BinaryExpression
}

Split receives a string and returns the parts of it splitted by a delimiter.

func (*Split) Eval

func (f *Split) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Split) IsNullable

func (f *Split) IsNullable() bool

IsNullable implements the Expression interface.

func (*Split) String

func (f *Split) String() string

func (*Split) TransformUp

func (f *Split) TransformUp(fn sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Split) Type

func (*Split) Type() sql.Type

Type implements the Expression interface.

type Substring

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

Substring is a function to return a part of a string. This function behaves as the homonym MySQL function. Since Go strings are UTF8, this function does not return a direct sub string str[start:start+length], instead returns the substring of rune s. That is, "á"[0:1] does not return a partial unicode glyph, but "á" itself.

func (*Substring) Children

func (s *Substring) Children() []sql.Expression

Children implements the Expression interface.

func (*Substring) Eval

func (s *Substring) Eval(
	ctx *sql.Context,
	row sql.Row,
) (interface{}, error)

Eval implements the Expression interface.

func (*Substring) IsNullable

func (s *Substring) IsNullable() bool

IsNullable implements the Expression interface.

func (*Substring) Resolved

func (s *Substring) Resolved() bool

Resolved implements the Expression interface.

func (*Substring) String

func (s *Substring) String() string

func (*Substring) TransformUp

func (s *Substring) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Substring) Type

func (*Substring) Type() sql.Type

Type implements the Expression interface.

type Year

type Year struct {
	expression.UnaryExpression
}

Year is a function that returns the year of a date.

func (*Year) Eval

func (y *Year) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Year) String

func (y *Year) String() string

func (*Year) TransformUp

func (y *Year) TransformUp(f sql.TransformExprFunc) (sql.Expression, error)

TransformUp implements the Expression interface.

func (*Year) Type

func (y *Year) Type() sql.Type

Type implements the Expression interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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