aggregation

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedJSONFunction = errors.NewKind("unsupported JSON function: %s")

ErrUnsupportedJSONFunction is returned when a unsupported JSON function is called.

Functions

func NewEmptyGroupConcat added in v0.10.0

func NewEmptyGroupConcat() sql.Expression

func NewJSONObjectAgg added in v0.9.0

func NewJSONObjectAgg(key, value sql.Expression) sql.Expression

NewJSONObjectAgg creates a new JSONArrayAgg function.

Types

type Avg

type Avg struct {
	expression.UnaryExpression
}

Avg node to calculate the average from numeric column

func NewAvg

func NewAvg(e sql.Expression) *Avg

NewAvg creates a new Avg node.

func (*Avg) Eval

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

Eval implements AggregationExpression interface. (AggregationExpression[Expression]])

func (*Avg) FunctionName

func (a *Avg) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Avg) IsNullable

func (a *Avg) IsNullable() bool

IsNullable implements AggregationExpression interface. (AggregationExpression[Expression]])

func (*Avg) Merge

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

Merge implements AggregationExpression interface. (AggregationExpression)

func (*Avg) NewBuffer

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

NewBuffer implements AggregationExpression interface. (AggregationExpression)

func (*Avg) String

func (a *Avg) String() string

func (*Avg) Type

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

Type implements AggregationExpression interface. (AggregationExpression[Expression]])

func (*Avg) Update

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

Update implements AggregationExpression interface. (AggregationExpression)

func (*Avg) WithChildren

func (a *Avg) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Count

type Count struct {
	expression.UnaryExpression
}

Count node to count how many rows are in the result set.

func NewCount

func NewCount(e sql.Expression) *Count

NewCount creates a new Count node.

func (*Count) Eval

func (c *Count) Eval(ctx *sql.Context, buffer sql.Row) (interface{}, error)

Eval implements the Aggregation interface.

func (*Count) FunctionName

func (c *Count) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Count) IsNullable

func (c *Count) IsNullable() bool

IsNullable returns whether the return value can be null.

func (*Count) Merge

func (c *Count) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*Count) NewBuffer

func (c *Count) NewBuffer() sql.Row

NewBuffer creates a new buffer for the aggregation.

func (*Count) Resolved

func (c *Count) Resolved() bool

Resolved implements the Expression interface.

func (*Count) String

func (c *Count) String() string

func (*Count) Type

func (c *Count) Type() sql.Type

Type returns the type of the result.

func (*Count) Update

func (c *Count) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*Count) WithChildren

func (c *Count) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type CountDistinct

type CountDistinct struct {
	expression.UnaryExpression
}

CountDistinct node to count how many rows are in the result set.

func NewCountDistinct

func NewCountDistinct(e sql.Expression) *CountDistinct

NewCountDistinct creates a new CountDistinct node.

func (*CountDistinct) Eval

func (c *CountDistinct) Eval(ctx *sql.Context, buffer sql.Row) (interface{}, error)

Eval implements the Aggregation interface.

func (*CountDistinct) IsNullable

func (c *CountDistinct) IsNullable() bool

IsNullable returns whether the return value can be null.

func (*CountDistinct) Merge

func (c *CountDistinct) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*CountDistinct) NewBuffer

func (c *CountDistinct) NewBuffer() sql.Row

NewBuffer creates a new buffer for the aggregation.

func (*CountDistinct) Resolved

func (c *CountDistinct) Resolved() bool

Resolved implements the Expression interface.

func (*CountDistinct) String

func (c *CountDistinct) String() string

func (*CountDistinct) Type

func (c *CountDistinct) Type() sql.Type

Type returns the type of the result.

func (*CountDistinct) Update

func (c *CountDistinct) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*CountDistinct) WithChildren

func (c *CountDistinct) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type First

type First struct {
	expression.UnaryExpression
}

First aggregation returns the first of all values in the selected column. It implements the Aggregation interface.

func NewFirst

func NewFirst(e sql.Expression) *First

NewFirst returns a new First node.

func (*First) Eval

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

Eval implements the Aggregation interface.

func (*First) FunctionName

func (f *First) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*First) Merge

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

Merge implements the Aggregation interface.

func (*First) NewBuffer

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

NewBuffer creates a new buffer to compute the result.

func (*First) String

func (f *First) String() string

func (*First) Type

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

Type returns the resultant type of the aggregation.

func (*First) Update

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

Update implements the Aggregation interface.

func (*First) WithChildren

func (f *First) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the sql.Expression interface.

type GroupConcat added in v0.10.0

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

func NewGroupConcat added in v0.10.0

func NewGroupConcat(distinct string, orderBy sql.SortFields, separator string, selectExprs []sql.Expression, maxLen int) (*GroupConcat, error)

func (*GroupConcat) Children added in v0.10.0

func (g *GroupConcat) Children() []sql.Expression

func (*GroupConcat) Eval added in v0.10.0

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

cc: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat

func (*GroupConcat) FunctionName added in v0.10.0

func (g *GroupConcat) FunctionName() string

func (*GroupConcat) IsNullable added in v0.10.0

func (g *GroupConcat) IsNullable() bool

func (*GroupConcat) Merge added in v0.10.0

func (g *GroupConcat) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*GroupConcat) NewBuffer added in v0.10.0

func (g *GroupConcat) NewBuffer() sql.Row

NewBuffer creates a new buffer for the aggregation.

func (*GroupConcat) Resolved added in v0.10.0

func (g *GroupConcat) Resolved() bool

func (*GroupConcat) String added in v0.10.0

func (g *GroupConcat) String() string

func (*GroupConcat) Type added in v0.10.0

func (g *GroupConcat) Type() sql.Type

cc: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat for explanations on return type.

func (*GroupConcat) Update added in v0.10.0

func (g *GroupConcat) Update(ctx *sql.Context, buffer, originalRow sql.Row) error

Update implements the Aggregation interface.

func (*GroupConcat) WithChildren added in v0.10.0

func (g *GroupConcat) WithChildren(children ...sql.Expression) (sql.Expression, error)

type JSONArrayAgg added in v0.9.0

type JSONArrayAgg struct {
	expression.UnaryExpression
}

JSON_ARRAYAGG(col_or_expr) [over_clause]

JSONArrayAgg Aggregates a result set as a single JSON array whose elements consist of the rows. The order of elements in this array is undefined. The function acts on a column or an expression that evaluates to a single value. Returns NULL if the result contains no rows, or in the event of an error.

https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-arrayagg

see also: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-normalization

func NewJSONArrayAgg added in v0.9.0

func NewJSONArrayAgg(arg sql.Expression) *JSONArrayAgg

NewJSONArrayAgg creates a new JSONArrayAgg function.

func (*JSONArrayAgg) Eval added in v0.9.0

func (j *JSONArrayAgg) Eval(ctx *sql.Context, buffer sql.Row) (interface{}, error)

Eval implements the Aggregation interface.

func (*JSONArrayAgg) FunctionName added in v0.9.0

func (j *JSONArrayAgg) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*JSONArrayAgg) IsNullable added in v0.9.0

func (j *JSONArrayAgg) IsNullable() bool

IsNullable returns whether the return value can be null.

func (*JSONArrayAgg) Merge added in v0.9.0

func (j *JSONArrayAgg) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*JSONArrayAgg) NewBuffer added in v0.9.0

func (j *JSONArrayAgg) NewBuffer() sql.Row

NewBuffer creates a new buffer for the aggregation.

func (*JSONArrayAgg) Resolved added in v0.9.0

func (j *JSONArrayAgg) Resolved() bool

Resolved implements the Expression interface.

func (*JSONArrayAgg) String added in v0.9.0

func (j *JSONArrayAgg) String() string

func (*JSONArrayAgg) Type added in v0.9.0

func (j *JSONArrayAgg) Type() sql.Type

Type returns the type of the result.

func (*JSONArrayAgg) Update added in v0.9.0

func (j *JSONArrayAgg) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*JSONArrayAgg) WithChildren added in v0.9.0

func (j *JSONArrayAgg) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type JSONObjectAgg added in v0.9.0

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

JSON_OBJECTAGG(key, value) [over_clause]

JSONObjectAgg Takes two column names or expressions as arguments, the first of these being used as a key and the second as a value, and returns a JSON object containing key-value pairs. Returns NULL if the result contains no rows, or in the event of an error. An error occurs if any key name is NULL or the number of arguments is not equal to 2.

https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg

see also: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-normalization

func (JSONObjectAgg) Children added in v0.9.0

func (j JSONObjectAgg) Children() []sql.Expression

func (JSONObjectAgg) Eval added in v0.9.0

func (j JSONObjectAgg) Eval(ctx *sql.Context, buffer sql.Row) (interface{}, error)

Eval implements the Aggregation interface.

func (JSONObjectAgg) FunctionName added in v0.9.0

func (j JSONObjectAgg) FunctionName() string

FunctionName implements sql.FunctionExpression

func (JSONObjectAgg) IsNullable added in v0.9.0

func (j JSONObjectAgg) IsNullable() bool

func (JSONObjectAgg) Merge added in v0.9.0

func (j JSONObjectAgg) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (JSONObjectAgg) NewBuffer added in v0.9.0

func (j JSONObjectAgg) NewBuffer() sql.Row

NewBuffer implements the Aggregation interface.

func (JSONObjectAgg) Resolved added in v0.9.0

func (j JSONObjectAgg) Resolved() bool

func (JSONObjectAgg) String added in v0.9.0

func (j JSONObjectAgg) String() string

func (JSONObjectAgg) Type added in v0.9.0

func (j JSONObjectAgg) Type() sql.Type

func (JSONObjectAgg) Update added in v0.9.0

func (j JSONObjectAgg) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (JSONObjectAgg) WithChildren added in v0.9.0

func (j JSONObjectAgg) WithChildren(children ...sql.Expression) (sql.Expression, error)

type Last

type Last struct {
	expression.UnaryExpression
}

Last aggregation returns the last of all values in the selected column. It implements the Aggregation interface.

func NewLast

func NewLast(e sql.Expression) *Last

NewLast returns a new Last node.

func (*Last) Eval

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

Eval implements the Aggregation interface.

func (*Last) FunctionName

func (l *Last) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Last) Merge

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

Merge implements the Aggregation interface.

func (*Last) NewBuffer

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

NewBuffer creates a new buffer to compute the result.

func (*Last) String

func (l *Last) String() string

func (*Last) Type

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

Type returns the resultant type of the aggregation.

func (*Last) Update

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

Update implements the Aggregation interface.

func (*Last) WithChildren

func (l *Last) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the sql.Expression interface.

type Max

type Max struct {
	expression.UnaryExpression
}

Max aggregation returns the greatest value of the selected column. It implements the Aggregation interface

func NewMax

func NewMax(e sql.Expression) *Max

NewMax returns a new Max node.

func (*Max) DebugString

func (m *Max) DebugString() string

func (*Max) Eval

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

Eval implements the Aggregation interface.

func (*Max) FunctionName

func (m *Max) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Max) IsNullable

func (m *Max) IsNullable() bool

IsNullable returns whether the return value can be null.

func (*Max) Merge

func (m *Max) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*Max) NewBuffer

func (m *Max) NewBuffer() sql.Row

NewBuffer creates a new buffer to compute the result.

func (*Max) String

func (m *Max) String() string

func (*Max) Type

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

Type returns the resultant type of the aggregation.

func (*Max) Update

func (m *Max) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*Max) WithChildren

func (m *Max) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Min

type Min struct {
	expression.UnaryExpression
}

Min aggregation returns the smallest value of the selected column. It implements the Aggregation interface

func NewMin

func NewMin(e sql.Expression) *Min

NewMin creates a new Min node.

func (*Min) Eval

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

Eval implements the Aggregation interface

func (*Min) FunctionName

func (m *Min) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Min) IsNullable

func (m *Min) IsNullable() bool

IsNullable returns whether the return value can be null.

func (*Min) Merge

func (m *Min) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*Min) NewBuffer

func (m *Min) NewBuffer() sql.Row

NewBuffer creates a new buffer to compute the result.

func (*Min) String

func (m *Min) String() string

func (*Min) Type

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

Type returns the resultant type of the aggregation.

func (*Min) Update

func (m *Min) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*Min) WithChildren

func (m *Min) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Sum

type Sum struct {
	expression.UnaryExpression
}

Sum aggregation returns the sum of all values in the selected column. It implements the Aggregation interface.

func NewSum

func NewSum(e sql.Expression) *Sum

NewSum returns a new Sum node.

func (*Sum) Eval

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

Eval implements the Aggregation interface.

func (*Sum) FunctionName

func (m *Sum) FunctionName() string

FunctionName implements sql.FunctionExpression

func (*Sum) Merge

func (m *Sum) Merge(ctx *sql.Context, buffer, partial sql.Row) error

Merge implements the Aggregation interface.

func (*Sum) NewBuffer

func (m *Sum) NewBuffer() sql.Row

NewBuffer creates a new buffer to compute the result.

func (*Sum) String

func (m *Sum) String() string

func (*Sum) Type

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

Type returns the resultant type of the aggregation.

func (*Sum) Update

func (m *Sum) Update(ctx *sql.Context, buffer, row sql.Row) error

Update implements the Aggregation interface.

func (*Sum) WithChildren

func (m *Sum) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren 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