aggregate

package
v0.0.0-...-714aee7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Functions

Aggregation Functions
as_list
as_list(expr)
as_list(expr,max_count)

Aggregates all rows of a column into a single array. The argument max_count specifies the maximum length. If this parameter is omitted, a reasonable default is choosen.

first
first(expr)

Aggregates all rows of a column by picking the first one.

last
last(expr)

Aggregates all rows of a column by picking the last one.

filter
filter(aggr,cond)

This function applies the given aggregation function aggr only on those rows, specified by cond.

group_by
group_by(key,aggr)
group_by(key,aggr,max_count)

This function works like a mixture of GROUP BY and as_list(...).

This function applies the given aggregation function aggr grouped by key. The result is returned as array. The argument max_count specifies the maximum length. If this parameter is omitted, a reasonable default is choosen.

This function is to be used instead of as_list(...), if the user wishes a deduplicated array:

group_by(my_column,first(my_column))
Regular functions
dict
dict(key1,value1,key2,value2,...)

This function creates a JSON-Style Object. Names and values must be interleaved.

array
array(value1,value2,value3)

This function creates a JSON-Style Array.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults = sql.Functions{

	"row_cluster": sql.FunctionN(NewRowCluster),

	"as_list": sql.FunctionN(NewAsList),
	"first":   sql.Function1(NewFirst),
	"last":    sql.Function1(NewLast),

	"filter":   sql.FunctionN(NewFilter),
	"group_by": sql.FunctionN(NewGroupBy),

	"dict":  sql.FunctionN(NewDict),
	"array": sql.FunctionN(NewArray),
}

Functions

func Clone

func Clone(o []sql.Expression) []sql.Expression

func NewArray

func NewArray(exprs ...sql.Expression) (sql.Expression, error)

func NewAsList

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

func NewDict

func NewDict(exprs ...sql.Expression) (sql.Expression, error)

func NewFilter

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

func NewFirst

func NewFirst(i sql.Expression) sql.Expression

func NewGroupBy

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

func NewLast

func NewLast(i sql.Expression) sql.Expression

func NewRowCluster

func NewRowCluster(exprs ...sql.Expression) (sql.Expression, error)

Types

type Array

type Array []sql.Expression

func (Array) Children

func (a Array) Children() []sql.Expression

Implements sql.Expression

func (Array) Eval

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

Implements sql.Expression

func (Array) IsNullable

func (a Array) IsNullable() bool

Implements sql.Expression

func (Array) Resolved

func (a Array) Resolved() (ok bool)

func (Array) String

func (a Array) String() string

func (Array) TransformUp

func (a Array) TransformUp(f sql.TransformExprFunc) (_ sql.Expression, e error)

Implements sql.Expression

func (Array) Type

func (a Array) Type() sql.Type

Implements sql.Expression

type AsList

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

func (*AsList) Children

func (a *AsList) Children() []sql.Expression

func (*AsList) Eval

func (a *AsList) Eval(_ *sql.Context, buffer sql.Row) (interface{}, error)

func (*AsList) IsNullable

func (a *AsList) IsNullable() bool

func (*AsList) Merge

func (a *AsList) Merge(ctx *sql.Context, buffer, partial sql.Row) error

func (*AsList) NewBuffer

func (a *AsList) NewBuffer() sql.Row

func (*AsList) Resolved

func (a *AsList) Resolved() (ok bool)

func (*AsList) String

func (a *AsList) String() string

func (*AsList) TransformUp

func (a *AsList) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

func (*AsList) Type

func (a *AsList) Type() sql.Type

func (*AsList) Update

func (a *AsList) Update(ctx *sql.Context, buffer, row sql.Row) error

type Dict

type Dict []sql.Expression

func (Dict) Children

func (a Dict) Children() []sql.Expression

Implements sql.Expression

func (Dict) Eval

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

Implements sql.Expression

func (Dict) IsNullable

func (a Dict) IsNullable() bool

Implements sql.Expression

func (Dict) Resolved

func (a Dict) Resolved() (ok bool)

func (Dict) String

func (a Dict) String() string

func (Dict) TransformUp

func (a Dict) TransformUp(f sql.TransformExprFunc) (_ sql.Expression, e error)

Implements sql.Expression

func (Dict) Type

func (a Dict) Type() sql.Type

Implements sql.Expression

type Filter

type Filter struct {
	Aggr sql.Aggregation
	Expr sql.Expression
}

func (*Filter) Children

func (a *Filter) Children() []sql.Expression

func (*Filter) Eval

func (a *Filter) Eval(_ *sql.Context, buffer sql.Row) (interface{}, error)

func (*Filter) IsNullable

func (a *Filter) IsNullable() bool

func (*Filter) Merge

func (a *Filter) Merge(ctx *sql.Context, buffer, partial sql.Row) error

func (*Filter) NewBuffer

func (a *Filter) NewBuffer() sql.Row

func (*Filter) Resolved

func (a *Filter) Resolved() (ok bool)

func (*Filter) String

func (a *Filter) String() string

func (*Filter) TransformUp

func (a *Filter) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

func (*Filter) Type

func (a *Filter) Type() sql.Type

func (*Filter) Update

func (a *Filter) Update(ctx *sql.Context, buffer, row sql.Row) error

type First

type First struct {
	Expr sql.Expression
}

func (*First) Children

func (a *First) Children() []sql.Expression

func (*First) Eval

func (a *First) Eval(_ *sql.Context, buffer sql.Row) (interface{}, error)

func (*First) IsNullable

func (a *First) IsNullable() bool

func (*First) Merge

func (a *First) Merge(ctx *sql.Context, buffer, partial sql.Row) error

func (*First) NewBuffer

func (a *First) NewBuffer() sql.Row

func (*First) Resolved

func (a *First) Resolved() (ok bool)

func (*First) String

func (a *First) String() string

func (*First) TransformUp

func (a *First) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

func (*First) Type

func (a *First) Type() sql.Type

func (*First) Update

func (a *First) Update(ctx *sql.Context, buffer, row sql.Row) error

type GroupBy

type GroupBy struct {
	Expr    sql.Expression
	Aggr    sql.Aggregation
	Maximum uint64
}

func (*GroupBy) Children

func (a *GroupBy) Children() []sql.Expression

func (*GroupBy) Eval

func (a *GroupBy) Eval(ctx *sql.Context, buffer sql.Row) (_ interface{}, e error)

func (*GroupBy) IsNullable

func (a *GroupBy) IsNullable() bool

func (*GroupBy) Merge

func (a *GroupBy) Merge(ctx *sql.Context, buffer, partial sql.Row) error

func (*GroupBy) NewBuffer

func (a *GroupBy) NewBuffer() sql.Row

func (*GroupBy) Resolved

func (a *GroupBy) Resolved() (ok bool)

func (*GroupBy) String

func (a *GroupBy) String() string

func (*GroupBy) TransformUp

func (a *GroupBy) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

func (*GroupBy) Type

func (a *GroupBy) Type() sql.Type

func (*GroupBy) Update

func (a *GroupBy) Update(ctx *sql.Context, buffer, row sql.Row) error

type Last

type Last struct {
	Expr sql.Expression
}

func (*Last) Children

func (a *Last) Children() []sql.Expression

func (*Last) Eval

func (a *Last) Eval(_ *sql.Context, buffer sql.Row) (interface{}, error)

func (*Last) IsNullable

func (a *Last) IsNullable() bool

func (*Last) Merge

func (a *Last) Merge(ctx *sql.Context, buffer, partial sql.Row) error

func (*Last) NewBuffer

func (a *Last) NewBuffer() sql.Row

func (*Last) Resolved

func (a *Last) Resolved() (ok bool)

func (*Last) String

func (a *Last) String() string

func (*Last) TransformUp

func (a *Last) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

func (*Last) Type

func (a *Last) Type() sql.Type

func (*Last) Update

func (a *Last) Update(ctx *sql.Context, buffer, row sql.Row) error

type RowCluster

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

func (RowCluster) Children

func (x RowCluster) Children() []sql.Expression

Implements sql.Expression

func (RowCluster) Eval

func (RowCluster) Eval(*sql.Context, sql.Row) (interface{}, error)

Implements sql.Expression

func (RowCluster) IsNullable

func (RowCluster) IsNullable() bool

Implements sql.Expression

func (RowCluster) Resolved

func (x RowCluster) Resolved() (ok bool)

Implements sql.Expression

func (RowCluster) String

func (r RowCluster) String() string

Implements sql.Expression

func (RowCluster) TransformUp

func (r RowCluster) TransformUp(st sql.TransformExprFunc) (sql.Expression, error)

Implements sql.Expression

func (RowCluster) Type

func (RowCluster) Type() sql.Type

Implements sql.Expression

Jump to

Keyboard shortcuts

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