Documentation
¶
Index ¶
- type Avg
- type AvgAggregator
- type Coalesce
- type Count
- type CountAggregator
- type Definition
- type Definitions
- type Len
- type Lower
- type Max
- type MaxAggregator
- type Min
- type MinAggregator
- type Now
- type ScalarDefinition
- type ScalarFunction
- type Sum
- type SumAggregator
- type Trim
- type TrimFunc
- type TypeOf
- type Upper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Avg ¶
Avg is the AVG aggregator function.
func (*Avg) Aggregator ¶
func (s *Avg) Aggregator() expr.Aggregator
Aggregator returns a Avg. It implements the AggregatorBuilder interface.
func (*Avg) Eval ¶
func (s *Avg) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the average value from the given object and returns it.
type AvgAggregator ¶
AvgAggregator is an aggregator that returns the average non-null value.
func (*AvgAggregator) Aggregate ¶
func (s *AvgAggregator) Aggregate(env *environment.Environment) error
Aggregate stores the average value of all non-NULL numeric values in the group.
func (*AvgAggregator) Eval ¶
func (s *AvgAggregator) Eval(_ *environment.Environment) (types.Value, error)
Eval returns the aggregated average as a double.
func (*AvgAggregator) String ¶
func (s *AvgAggregator) String() string
type Coalesce ¶
func (*Coalesce) Eval ¶
func (c *Coalesce) Eval(e *environment.Environment) (types.Value, error)
type Count ¶
Count is the COUNT aggregator function. It counts the number of objects in a stream.
func (*Count) Aggregator ¶
func (c *Count) Aggregator() expr.Aggregator
Aggregator returns a CountAggregator. It implements the AggregatorBuilder interface.
func (*Count) Eval ¶
func (c *Count) Eval(env *environment.Environment) (types.Value, error)
type CountAggregator ¶
CountAggregator is an aggregator that counts non-null expressions.
func (*CountAggregator) Aggregate ¶
func (c *CountAggregator) Aggregate(env *environment.Environment) error
Aggregate increments the counter if the count expression evaluates to a non-null value.
func (*CountAggregator) Eval ¶
func (c *CountAggregator) Eval(_ *environment.Environment) (types.Value, error)
Eval returns the result of the aggregation as an integer.
func (*CountAggregator) String ¶
func (c *CountAggregator) String() string
type Definition ¶
type Definition interface {
Name() string
String() string
Function(...expr.Expr) (expr.Function, error)
}
A Definition transforms a list of expressions into a Function.
func GetFunc ¶ added in v0.17.0
func GetFunc(fname string) (Definition, error)
GetFunc return a function definition by its package and name.
type Definitions ¶
type Definitions map[string]Definition
Definitions table holds a map of definition, indexed by their names.
type Len ¶
Len represents the len() function. It returns the length of string, array or row. For other types len() returns NULL.
func (*Len) Eval ¶
func (s *Len) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the average value from the given object and returns it.
type Lower ¶
Lower is the LOWER function It returns the lower-case version of a string
func (*Lower) Eval ¶
func (s *Lower) Eval(env *environment.Environment) (types.Value, error)
type Max ¶
Max is the MAX aggregator function.
func (*Max) Aggregator ¶
func (m *Max) Aggregator() expr.Aggregator
Aggregator returns a MaxAggregator. It implements the AggregatorBuilder interface.
func (*Max) Eval ¶
func (m *Max) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the max value from the given object and returns it.
type MaxAggregator ¶
MaxAggregator is an aggregator that returns the minimum non-null value.
func (*MaxAggregator) Aggregate ¶
func (m *MaxAggregator) Aggregate(env *environment.Environment) error
Aggregate stores the maximum value. Values are compared based on their types, then if the type is equal their value is compared. Numbers are considered of the same type.
func (*MaxAggregator) Eval ¶
func (m *MaxAggregator) Eval(_ *environment.Environment) (types.Value, error)
Eval return the maximum value.
func (*MaxAggregator) String ¶
func (m *MaxAggregator) String() string
type Min ¶
Min is the MIN aggregator function.
func (*Min) Aggregator ¶
func (m *Min) Aggregator() expr.Aggregator
Aggregator returns a MinAggregator. It implements the AggregatorBuilder interface.
func (*Min) Eval ¶
func (m *Min) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the min value from the given object and returns it.
type MinAggregator ¶
MinAggregator is an aggregator that returns the minimum non-null value.
func (*MinAggregator) Aggregate ¶
func (m *MinAggregator) Aggregate(env *environment.Environment) error
Aggregate stores the minimum value. Values are compared based on their types, then if the type is equal their value is compared. Numbers are considered of the same type.
func (*MinAggregator) Eval ¶
func (m *MinAggregator) Eval(_ *environment.Environment) (types.Value, error)
Eval return the minimum value.
func (*MinAggregator) String ¶
func (m *MinAggregator) String() string
type Now ¶
type Now struct{}
func (*Now) Eval ¶
func (n *Now) Eval(env *environment.Environment) (types.Value, error)
type ScalarDefinition ¶
type ScalarDefinition struct {
// contains filtered or unexported fields
}
A ScalarDefinition is the definition type for functions which operates on scalar values in contrast to other SQL functions such as the SUM aggregator which operates on expressions instead.
This difference allows to simply define them with a CallFn function that takes multiple row.Value and return another types.Value, rather than having to manually evaluate expressions (see Definition).
func NewScalarDefinition ¶
func (*ScalarDefinition) Name ¶
func (fd *ScalarDefinition) Name() string
Name returns the defined function named (as an ident, so no parentheses).
func (*ScalarDefinition) String ¶
func (fd *ScalarDefinition) String() string
String returns the defined function name and its arguments.
type ScalarFunction ¶
type ScalarFunction struct {
// contains filtered or unexported fields
}
A ScalarFunction is a function which operates on scalar values in contrast to other SQL functions such as the SUM aggregator wich operates on expressions instead.
func (*ScalarFunction) Clone ¶ added in v0.17.0
func (sf *ScalarFunction) Clone() expr.Expr
func (*ScalarFunction) Eval ¶
func (sf *ScalarFunction) Eval(env *environment.Environment) (types.Value, error)
Eval returns a row.Value based on the given environment and the underlying function definition.
func (*ScalarFunction) Params ¶
func (sf *ScalarFunction) Params() []expr.Expr
Params return the function arguments.
func (*ScalarFunction) String ¶
func (sf *ScalarFunction) String() string
String returns a string represention of the function expression and its arguments.
type Sum ¶
Sum is the SUM aggregator function.
func (*Sum) Aggregator ¶
func (s *Sum) Aggregator() expr.Aggregator
Aggregator returns a Sum. It implements the AggregatorBuilder interface.
func (*Sum) Eval ¶
func (s *Sum) Eval(env *environment.Environment) (types.Value, error)
Eval extracts the sum value from the given object and returns it.
type SumAggregator ¶
SumAggregator is an aggregator that returns the minimum non-null value.
func (*SumAggregator) Aggregate ¶
func (s *SumAggregator) Aggregate(env *environment.Environment) error
Aggregate stores the sum of all non-NULL numeric values in the group. The result is an integer value if all summed values are integers. If any of the value is a double, the returned result will be a double.
func (*SumAggregator) Eval ¶
func (s *SumAggregator) Eval(_ *environment.Environment) (types.Value, error)
Eval return the aggregated sum.
func (*SumAggregator) String ¶
func (s *SumAggregator) String() string
type Trim ¶
TRIM removes leading and trailing characters from a string based on the given input. LTRIM removes leading characters RTRIM removes trailing characters By default remove space " "
func (*Trim) Eval ¶
func (s *Trim) Eval(env *environment.Environment) (types.Value, error)
type TypeOf ¶
func (*TypeOf) Eval ¶
func (t *TypeOf) Eval(env *environment.Environment) (types.Value, error)
type Upper ¶
Upper is the UPPER function It returns the upper-case version of a string
func (*Upper) Eval ¶
func (s *Upper) Eval(env *environment.Environment) (types.Value, error)