Documentation
¶
Overview ¶
Package expr provides types and builders for constructing Substrait expressions.
IMPORTANT: Only ExprBuilder methods guarantee construction of valid expressions. Manual construction using struct literals bypasses validation and may create invalid expressions. It is highly recommended to only construct expressions via the builders
Index ¶
- func DecimalStringToBytes(decimalStr string) ([16]byte, int32, int32, error)
- func DecimalToBytes(dec *apd.Decimal) ([16]byte, int32, int32, error)
- func FuncArgFromProto(e *proto.FunctionArgument, baseSchema *types.RecordType, reg ExtensionRegistry) (types.FuncArg, error)
- func FuncArgsEqual(a, b types.FuncArg) bool
- type AggregateFunction
- func NewAggregateFunc(reg ExtensionRegistry, id extensions.ID, opts []*types.FunctionOption, ...) (*AggregateFunction, error)
- func NewAggregateFunctionFromProto(agg *proto.AggregateFunction, baseSchema *types.RecordType, ...) (*AggregateFunction, error)
- func NewCustomAggregateFunc(reg ExtensionRegistry, v *extensions.AggregateFunctionVariant, ...) (*AggregateFunction, error)
- func (a *AggregateFunction) Arg(i int) types.FuncArg
- func (a *AggregateFunction) Clone() *AggregateFunction
- func (a *AggregateFunction) CompoundName() string
- func (a *AggregateFunction) Decomposable() extensions.DecomposeType
- func (a *AggregateFunction) Deterministic() bool
- func (a *AggregateFunction) GetArgTypes() []types.Type
- func (a *AggregateFunction) GetOption(name string) []string
- func (a *AggregateFunction) GetOptions() []*types.FunctionOption
- func (a *AggregateFunction) GetType() types.Type
- func (a *AggregateFunction) ID() extensions.ID
- func (a *AggregateFunction) IntermediateType() (types.FuncDefArgType, error)
- func (a *AggregateFunction) Invocation() types.AggregationInvocation
- func (a *AggregateFunction) MaxSet() int
- func (a *AggregateFunction) NArgs() int
- func (a *AggregateFunction) Name() string
- func (a *AggregateFunction) Ordered() bool
- func (a *AggregateFunction) Phase() types.AggregationPhase
- func (a *AggregateFunction) SessionDependant() bool
- func (a *AggregateFunction) SetArg(i int, arg types.FuncArg)
- func (a *AggregateFunction) String() string
- func (a *AggregateFunction) ToProto() *proto.AggregateFunction
- func (a *AggregateFunction) Variadic() *extensions.VariadicBehavior
- type Bound
- type Builder
- type ByteSliceLiteral
- func (t *ByteSliceLiteral[T]) Equals(rhs Expression) bool
- func (t *ByteSliceLiteral[T]) GetType() types.Type
- func (*ByteSliceLiteral[T]) IsScalar() bool
- func (t *ByteSliceLiteral[T]) String() string
- func (t *ByteSliceLiteral[T]) ToProto() *proto.Expression
- func (t *ByteSliceLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
- func (t *ByteSliceLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
- func (t *ByteSliceLiteral[T]) ValueString() string
- func (t *ByteSliceLiteral[T]) Visit(VisitFunc) Expression
- func (t *ByteSliceLiteral[T]) WithType(newType types.Type) (Literal, error)
- type Cast
- type CurrentRow
- type DynamicParameter
- func (dp *DynamicParameter) Equals(other Expression) bool
- func (dp *DynamicParameter) GetType() types.Type
- func (dp *DynamicParameter) IsScalar() bool
- func (dp *DynamicParameter) String() string
- func (dp *DynamicParameter) ToProto() *proto.Expression
- func (dp *DynamicParameter) ToProtoFuncArg() *proto.FunctionArgument
- func (dp *DynamicParameter) Visit(visit VisitFunc) Expression
- type ExprBuilder
- func (e *ExprBuilder) AggFunc(id extensions.ID, opts ...*types.FunctionOption) *aggregateFuncBuilder
- func (e *ExprBuilder) Cast(from Builder, to types.Type) *castBuilder
- func (e *ExprBuilder) DynamicParam(outputType types.Type, paramRef uint32) *dynamicParamBuilder
- func (e *ExprBuilder) Enum(val string) enumWrapper
- func (e *ExprBuilder) Expression(expr Expression) exprWrapper
- func (e *ExprBuilder) Lambda(params *types.StructType, body Builder) *lambdaBuilder
- func (e *ExprBuilder) LambdaParamRef(ref StructFieldRef, stepsOut uint32) *lambdaParamRefBuilder
- func (e *ExprBuilder) Literal(l Literal) exprWrapper
- func (e *ExprBuilder) Ref(root RootRefType, ref Reference) *fieldRefBuilder
- func (e *ExprBuilder) RootRef(ref Reference) *fieldRefBuilder
- func (e *ExprBuilder) ScalarFunc(id extensions.ID, opts ...*types.FunctionOption) *scalarFuncBuilder
- func (e *ExprBuilder) WindowFunc(id extensions.ID, opts ...*types.FunctionOption) *windowFuncBuilder
- func (e *ExprBuilder) Wrap(l Literal, err error) exprWrapper
- type Expression
- type ExpressionReference
- func (er *ExpressionReference) GetExpr() Expression
- func (er *ExpressionReference) GetMeasure() *AggregateFunction
- func (er *ExpressionReference) SetExpr(ex Expression)
- func (er *ExpressionReference) SetMeasure(m *AggregateFunction)
- func (er *ExpressionReference) ToProto() *proto.ExpressionReference
- type Extended
- type ExtensionRegistry
- func (e *ExtensionRegistry) ExtensionsToProto() ([]*extensionspb.SimpleExtensionURN, []*extensionspb.SimpleExtensionDeclaration)
- func (e *ExtensionRegistry) LookupAggregateFunction(anchor uint32) (*extensions.AggregateFunctionVariant, bool)
- func (e *ExtensionRegistry) LookupScalarFunction(anchor uint32) (*extensions.ScalarFunctionVariant, bool)
- func (e *ExtensionRegistry) LookupType(anchor uint32) (extensions.Type, bool)
- func (e *ExtensionRegistry) LookupTypeVariation(anchor uint32) (extensions.TypeVariation, bool)
- func (e *ExtensionRegistry) LookupWindowFunction(anchor uint32) (*extensions.WindowFunctionVariant, bool)
- func (e *ExtensionRegistry) SetSubqueryConverter(converter subqueryConverter)
- type FieldReference
- func FieldReferenceFromProto(p *proto.Expression_FieldReference, baseSchema *types.RecordType, ...) (*FieldReference, error)
- func NewFieldRef(root RootRefType, ref Reference, baseSchema *types.RecordType) (*FieldReference, error)
- func NewFieldRefFromType(root RootRefType, ref Reference, t types.Type) (*FieldReference, error)
- func NewRootFieldRef(ref Reference, baseSchema *types.RecordType) (*FieldReference, error)
- func NewRootFieldRefFromType(ref Reference, t types.Type) (*FieldReference, error)
- func (f *FieldReference) Equals(rhs Expression) bool
- func (f *FieldReference) GetType() types.Type
- func (*FieldReference) IsScalar() bool
- func (f *FieldReference) String() string
- func (f *FieldReference) ToProto() *proto.Expression
- func (f *FieldReference) ToProtoFieldRef() *proto.Expression_FieldReference
- func (f *FieldReference) ToProtoFuncArg() *proto.FunctionArgument
- func (f *FieldReference) Visit(v VisitFunc) Expression
- type FollowingBound
- type FuncArgBuilder
- type FunctionInvocation
- type IfThen
- func (ex *IfThen) Else() Expression
- func (ex *IfThen) Equals(other Expression) bool
- func (ex *IfThen) GetType() types.Type
- func (ex *IfThen) IfPair(i int) IfThenPair
- func (ex *IfThen) IsScalar() bool
- func (ex *IfThen) NIfs() int
- func (ex *IfThen) String() string
- func (ex *IfThen) ToProto() *proto.Expression
- func (ex *IfThen) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *IfThen) Visit(visit VisitFunc) Expression
- type IfThenPair
- type IntervalCompoundLiteral
- func (m IntervalCompoundLiteral) Equals(rhs Expression) bool
- func (m IntervalCompoundLiteral) GetType() types.Type
- func (IntervalCompoundLiteral) IsScalar() bool
- func (m IntervalCompoundLiteral) String() string
- func (m IntervalCompoundLiteral) ToProto() *proto.Expression
- func (m IntervalCompoundLiteral) ToProtoFuncArg() *proto.FunctionArgument
- func (m IntervalCompoundLiteral) ToProtoLiteral() *proto.Expression_Literal
- func (m IntervalCompoundLiteral) ValueString() string
- func (m IntervalCompoundLiteral) Visit(VisitFunc) Expression
- type IntervalYearToMonthLiteral
- func (m IntervalYearToMonthLiteral) Equals(rhs Expression) bool
- func (m IntervalYearToMonthLiteral) GetType() types.Type
- func (IntervalYearToMonthLiteral) IsScalar() bool
- func (m IntervalYearToMonthLiteral) String() string
- func (m IntervalYearToMonthLiteral) ToProto() *proto.Expression
- func (m IntervalYearToMonthLiteral) ToProtoFuncArg() *proto.FunctionArgument
- func (m IntervalYearToMonthLiteral) ToProtoLiteral() *proto.Expression_Literal
- func (m IntervalYearToMonthLiteral) ValueString() string
- func (m IntervalYearToMonthLiteral) Visit(VisitFunc) Expression
- type Lambda
- func (l *Lambda) Equals(other Expression) bool
- func (l *Lambda) GetType() types.Type
- func (l *Lambda) IsScalar() bool
- func (l *Lambda) String() string
- func (l *Lambda) ToProto() *proto.Expression
- func (l *Lambda) ToProtoFuncArg() *proto.FunctionArgument
- func (l *Lambda) Visit(visit VisitFunc) Expression
- type LambdaParameterReference
- type ListElementRef
- type ListExpr
- func (ex *ListExpr) Equals(other Expression) bool
- func (ex *ListExpr) GetType() types.Type
- func (ex *ListExpr) IsNullable() bool
- func (ex *ListExpr) IsScalar() bool
- func (ex *ListExpr) String() string
- func (ex *ListExpr) ToProto() *proto.Expression
- func (ex *ListExpr) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *ListExpr) TypeVariation() uint32
- func (ex *ListExpr) Visit(visit VisitFunc) Expression
- type ListLiteral
- type ListLiteralValue
- type Literal
- func LiteralFromProto(l *proto.Expression_Literal) Literal
- func NewLiteral[T allLiteralTypes](val T, nullable bool) (Literal, error)
- func NewNestedLiteral[T StructLiteralValue | MapLiteralValue | ListLiteralValue](val T, nullable bool) Literal
- func NewPrecisionTimeLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
- func NewPrecisionTimestampLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
- func NewPrecisionTimestampTzLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
- func NewPrimitiveLiteral[T newPrimitiveLiteralTypes](val T, nullable bool) Literal
- type MapExpr
- func (ex *MapExpr) Equals(other Expression) bool
- func (ex *MapExpr) GetType() types.Type
- func (ex *MapExpr) IsNullable() bool
- func (ex *MapExpr) IsScalar() bool
- func (ex *MapExpr) String() string
- func (ex *MapExpr) ToProto() *proto.Expression
- func (ex *MapExpr) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *MapExpr) TypeVariation() uint32
- func (ex *MapExpr) Visit(visit VisitFunc) Expression
- type MapKeyRef
- type MapLiteral
- func (t *MapLiteral) Equals(rhs Expression) bool
- func (t *MapLiteral) GetType() types.Type
- func (*MapLiteral) IsScalar() bool
- func (t *MapLiteral) String() string
- func (t *MapLiteral) ToProto() *proto.Expression
- func (t *MapLiteral) ToProtoFuncArg() *proto.FunctionArgument
- func (t *MapLiteral) ToProtoLiteral() *proto.Expression_Literal
- func (t *MapLiteral) ValueString() string
- func (t *MapLiteral) Visit(VisitFunc) Expression
- type MapLiteralValue
- type MapSelectKind
- type MaskExpression
- type MaskListElement
- type MaskListSelect
- type MaskListSelectItem
- type MaskListSlice
- type MaskMapSelect
- type MaskSelect
- type MaskStructItem
- type MaskStructSelect
- type MultiOrList
- func (ex *MultiOrList) Equals(other Expression) bool
- func (ex *MultiOrList) GetType() types.Type
- func (ex *MultiOrList) IsScalar() bool
- func (ex *MultiOrList) String() string
- func (ex *MultiOrList) ToProto() *proto.Expression
- func (ex *MultiOrList) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *MultiOrList) Visit(visit VisitFunc) Expression
- type NestedExpr
- type NestedLiteral
- func (t *NestedLiteral[T]) Equals(rhs Expression) bool
- func (t *NestedLiteral[T]) GetType() types.Type
- func (*NestedLiteral[T]) IsScalar() bool
- func (t *NestedLiteral[T]) String() string
- func (t *NestedLiteral[T]) ToProto() *proto.Expression
- func (t *NestedLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
- func (t *NestedLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
- func (t *NestedLiteral[T]) ValueString() string
- func (t *NestedLiteral[T]) Visit(VisitFunc) Expression
- func (t *NestedLiteral[T]) WithType(newType types.Type) (Literal, error)
- type Null
- type NullLiteral
- func (n *NullLiteral) Equals(rhs Expression) bool
- func (n *NullLiteral) GetType() types.Type
- func (*NullLiteral) IsScalar() bool
- func (n *NullLiteral) String() string
- func (n *NullLiteral) ToProto() *proto.Expression
- func (n *NullLiteral) ToProtoFuncArg() *proto.FunctionArgument
- func (n *NullLiteral) ToProtoLiteral() *proto.Expression_Literal
- func (n *NullLiteral) ValueString() string
- func (n *NullLiteral) Visit(VisitFunc) Expression
- type OuterReference
- type PrecedingBound
- type PrimitiveLiteral
- func (t *PrimitiveLiteral[T]) Equals(rhs Expression) bool
- func (t *PrimitiveLiteral[T]) GetType() types.Type
- func (*PrimitiveLiteral[T]) IsScalar() bool
- func (t *PrimitiveLiteral[T]) IsoValueString() string
- func (t *PrimitiveLiteral[T]) String() string
- func (t *PrimitiveLiteral[T]) ToProto() *proto.Expression
- func (t *PrimitiveLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
- func (t *PrimitiveLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
- func (t *PrimitiveLiteral[T]) ValueString() string
- func (t *PrimitiveLiteral[T]) Visit(VisitFunc) Expression
- func (t *PrimitiveLiteral[T]) WithType(newType types.Type) (Literal, error)
- type PrimitiveLiteralValue
- type ProtoLiteral
- func (t *ProtoLiteral) Equals(rhs Expression) bool
- func (t *ProtoLiteral) GetType() types.Type
- func (*ProtoLiteral) IsScalar() bool
- func (t *ProtoLiteral) IsoValueString() string
- func (t *ProtoLiteral) String() string
- func (t *ProtoLiteral) ToProto() *proto.Expression
- func (t *ProtoLiteral) ToProtoFuncArg() *proto.FunctionArgument
- func (t *ProtoLiteral) ToProtoLiteral() *proto.Expression_Literal
- func (t *ProtoLiteral) ValueString() string
- func (t *ProtoLiteral) Visit(VisitFunc) Expression
- func (t *ProtoLiteral) WithType(newType types.Type) (Literal, error)
- type Reference
- type ReferenceSegment
- type RootRefType
- type ScalarFunction
- func (s *ScalarFunction) Arg(i int) types.FuncArg
- func (s *ScalarFunction) CompoundName() string
- func (s *ScalarFunction) Deterministic() bool
- func (s *ScalarFunction) Equals(rhs Expression) bool
- func (s *ScalarFunction) FuncRef() uint32
- func (s *ScalarFunction) GetArgTypes() []types.Type
- func (s *ScalarFunction) GetOption(name string) []string
- func (s *ScalarFunction) GetOptions() []*types.FunctionOption
- func (s *ScalarFunction) GetType() types.Type
- func (s *ScalarFunction) ID() extensions.ID
- func (s *ScalarFunction) IsScalar() bool
- func (s *ScalarFunction) NArgs() int
- func (s *ScalarFunction) Name() string
- func (s *ScalarFunction) SessionDependant() bool
- func (s *ScalarFunction) String() string
- func (s *ScalarFunction) ToProto() *proto.Expression
- func (s *ScalarFunction) ToProtoFuncArg() *proto.FunctionArgument
- func (s *ScalarFunction) Variadic() *extensions.VariadicBehavior
- func (s *ScalarFunction) Visit(visit VisitFunc) Expression
- type SingularOrList
- func (ex *SingularOrList) Equals(other Expression) bool
- func (ex *SingularOrList) GetType() types.Type
- func (ex *SingularOrList) IsScalar() bool
- func (ex *SingularOrList) String() string
- func (ex *SingularOrList) ToProto() *proto.Expression
- func (ex *SingularOrList) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *SingularOrList) Visit(visit VisitFunc) Expression
- type SortField
- type StructExpr
- func (ex *StructExpr) Equals(other Expression) bool
- func (ex *StructExpr) GetType() types.Type
- func (ex *StructExpr) IsNullable() bool
- func (ex *StructExpr) IsScalar() bool
- func (ex *StructExpr) String() string
- func (ex *StructExpr) ToProto() *proto.Expression
- func (ex *StructExpr) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *StructExpr) TypeVariation() uint32
- func (ex *StructExpr) Visit(visit VisitFunc) Expression
- type StructFieldRef
- type StructLiteral
- type StructLiteralValue
- type SwitchExpr
- func (ex *SwitchExpr) Case(i int) struct{ ... }
- func (ex *SwitchExpr) Else() Expression
- func (ex *SwitchExpr) Equals(other Expression) bool
- func (ex *SwitchExpr) GetType() types.Type
- func (ex *SwitchExpr) IsScalar() bool
- func (ex *SwitchExpr) MatchExpr() Expression
- func (ex *SwitchExpr) NCases() int
- func (ex *SwitchExpr) String() string
- func (ex *SwitchExpr) ToProto() *proto.Expression
- func (ex *SwitchExpr) ToProtoFuncArg() *proto.FunctionArgument
- func (ex *SwitchExpr) Visit(visit VisitFunc) Expression
- type Unbounded
- type VirtualTableExpressionValue
- type VisitFunc
- type WindowFunction
- func (w *WindowFunction) Arg(i int) types.FuncArg
- func (w *WindowFunction) CompoundName() string
- func (w *WindowFunction) Decomposable() extensions.DecomposeType
- func (w *WindowFunction) Deterministic() bool
- func (w *WindowFunction) Equals(other Expression) bool
- func (w *WindowFunction) GetArgTypes() []types.Type
- func (w *WindowFunction) GetOptions() []*types.FunctionOption
- func (w *WindowFunction) GetType() types.Type
- func (w *WindowFunction) ID() extensions.ID
- func (w *WindowFunction) IntermediateType() (types.FuncDefArgType, error)
- func (w *WindowFunction) Invocation() types.AggregationInvocation
- func (*WindowFunction) IsScalar() bool
- func (w *WindowFunction) MaxSet() int
- func (w *WindowFunction) NArgs() int
- func (w *WindowFunction) Name() string
- func (w *WindowFunction) Ordered() bool
- func (w *WindowFunction) Phase() types.AggregationPhase
- func (w *WindowFunction) SessionDependant() bool
- func (w *WindowFunction) String() string
- func (w *WindowFunction) ToProto() *proto.Expression
- func (w *WindowFunction) ToProtoFuncArg() *proto.FunctionArgument
- func (w *WindowFunction) Variadic() *extensions.VariadicBehavior
- func (w *WindowFunction) Visit(visit VisitFunc) Expression
- func (w *WindowFunction) WindowType() extensions.WindowType
- type WithTypeLiteral
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecimalStringToBytes ¶
DecimalStringToBytes converts a decimal string to a 16-byte byte array. 16-byte bytes represents a little-endian 128-bit integer, to be divided by 10^Scale to get the decimal value. This function also returns the precision and scale of the decimal value. The precision is the total number of digits in the decimal value. The precision is limited to 38 digits. The scale is the number of digits to the right of the decimal point. The scale is limited to the precision.
func DecimalToBytes ¶
DecimalToBytes converts apd.Decimal to a 16-byte byte array. 16-byte bytes represents a little-endian 128-bit integer, to be divided by 10^Scale to get the decimal value. This function also returns the precision and scale of the decimal value.
func FuncArgFromProto ¶
func FuncArgFromProto(e *proto.FunctionArgument, baseSchema *types.RecordType, reg ExtensionRegistry) (types.FuncArg, error)
func FuncArgsEqual ¶
Types ¶
type AggregateFunction ¶
type AggregateFunction struct {
Sorts []SortField
// contains filtered or unexported fields
}
func NewAggregateFunc ¶
func NewAggregateFunc( reg ExtensionRegistry, id extensions.ID, opts []*types.FunctionOption, invoke types.AggregationInvocation, phase types.AggregationPhase, sorts []SortField, args ...types.FuncArg, ) (*AggregateFunction, error)
func NewAggregateFunctionFromProto ¶
func NewAggregateFunctionFromProto( agg *proto.AggregateFunction, baseSchema *types.RecordType, reg ExtensionRegistry, ) (*AggregateFunction, error)
func NewCustomAggregateFunc ¶
func NewCustomAggregateFunc( reg ExtensionRegistry, v *extensions.AggregateFunctionVariant, outputType types.Type, opts []*types.FunctionOption, invoke types.AggregationInvocation, phase types.AggregationPhase, sorts []SortField, args ...types.FuncArg, ) (*AggregateFunction, error)
func (*AggregateFunction) Clone ¶
func (a *AggregateFunction) Clone() *AggregateFunction
func (*AggregateFunction) CompoundName ¶
func (a *AggregateFunction) CompoundName() string
func (*AggregateFunction) Decomposable ¶
func (a *AggregateFunction) Decomposable() extensions.DecomposeType
func (*AggregateFunction) Deterministic ¶
func (a *AggregateFunction) Deterministic() bool
func (*AggregateFunction) GetArgTypes ¶
func (a *AggregateFunction) GetArgTypes() []types.Type
func (*AggregateFunction) GetOption ¶
func (a *AggregateFunction) GetOption(name string) []string
func (*AggregateFunction) GetOptions ¶
func (a *AggregateFunction) GetOptions() []*types.FunctionOption
func (*AggregateFunction) GetType ¶
func (a *AggregateFunction) GetType() types.Type
func (*AggregateFunction) ID ¶
func (a *AggregateFunction) ID() extensions.ID
func (*AggregateFunction) IntermediateType ¶
func (a *AggregateFunction) IntermediateType() (types.FuncDefArgType, error)
func (*AggregateFunction) Invocation ¶
func (a *AggregateFunction) Invocation() types.AggregationInvocation
func (*AggregateFunction) MaxSet ¶
func (a *AggregateFunction) MaxSet() int
func (*AggregateFunction) NArgs ¶
func (a *AggregateFunction) NArgs() int
func (*AggregateFunction) Name ¶
func (a *AggregateFunction) Name() string
func (*AggregateFunction) Ordered ¶
func (a *AggregateFunction) Ordered() bool
func (*AggregateFunction) Phase ¶
func (a *AggregateFunction) Phase() types.AggregationPhase
func (*AggregateFunction) SessionDependant ¶
func (a *AggregateFunction) SessionDependant() bool
func (*AggregateFunction) SetArg ¶
func (a *AggregateFunction) SetArg(i int, arg types.FuncArg)
SetArg sets the specified argument to the provided value. The index is not checked for validity.
func (*AggregateFunction) String ¶
func (a *AggregateFunction) String() string
func (*AggregateFunction) ToProto ¶
func (a *AggregateFunction) ToProto() *proto.AggregateFunction
func (*AggregateFunction) Variadic ¶
func (a *AggregateFunction) Variadic() *extensions.VariadicBehavior
type Bound ¶
type Bound interface {
fmt.Stringer
ToProto() *proto.Expression_WindowFunction_Bound
}
func BoundFromProto ¶
func BoundFromProto(b *proto.Expression_WindowFunction_Bound) Bound
type Builder ¶
type Builder interface {
BuildExpr() (Expression, error)
}
Builder is a basic interface for any type which can construct an expression. The `Build` method will be reserved for producing a concrete type while `BuildExpr` will exist for compatibility with this interface for ease of use. Typically it will be implemented as a simply a call to Build anyways.
type ByteSliceLiteral ¶
ByteSliceLiteral is any literal that is represented as a byte slice. As opposed to a string literal which can be compared with ==, a byte slice needs to use something like bytes.Equal
func NewByteSliceLiteral ¶
func NewByteSliceLiteral[T []byte | types.UUID](val T, nullable bool) *ByteSliceLiteral[T]
func NewFixedBinaryLiteral ¶
func NewFixedBinaryLiteral(val types.FixedBinary, nullable bool) *ByteSliceLiteral[types.FixedBinary]
func (*ByteSliceLiteral[T]) Equals ¶
func (t *ByteSliceLiteral[T]) Equals(rhs Expression) bool
func (*ByteSliceLiteral[T]) GetType ¶
func (t *ByteSliceLiteral[T]) GetType() types.Type
func (*ByteSliceLiteral[T]) IsScalar ¶
func (*ByteSliceLiteral[T]) IsScalar() bool
func (*ByteSliceLiteral[T]) String ¶
func (t *ByteSliceLiteral[T]) String() string
func (*ByteSliceLiteral[T]) ToProto ¶
func (t *ByteSliceLiteral[T]) ToProto() *proto.Expression
func (*ByteSliceLiteral[T]) ToProtoFuncArg ¶
func (t *ByteSliceLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
func (*ByteSliceLiteral[T]) ToProtoLiteral ¶
func (t *ByteSliceLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
func (*ByteSliceLiteral[T]) ValueString ¶
func (t *ByteSliceLiteral[T]) ValueString() string
func (*ByteSliceLiteral[T]) Visit ¶
func (t *ByteSliceLiteral[T]) Visit(VisitFunc) Expression
type Cast ¶
type Cast struct {
Type types.Type
Input Expression
FailureBehavior types.CastFailBehavior
}
func (*Cast) Equals ¶
func (ex *Cast) Equals(other Expression) bool
func (*Cast) ToProto ¶
func (ex *Cast) ToProto() *proto.Expression
func (*Cast) ToProtoFuncArg ¶
func (ex *Cast) ToProtoFuncArg() *proto.FunctionArgument
func (*Cast) Visit ¶
func (ex *Cast) Visit(visit VisitFunc) Expression
type CurrentRow ¶
type CurrentRow struct{}
func (CurrentRow) String ¶
func (CurrentRow) String() string
func (CurrentRow) ToProto ¶
func (CurrentRow) ToProto() *proto.Expression_WindowFunction_Bound
type DynamicParameter ¶
func (*DynamicParameter) Equals ¶
func (dp *DynamicParameter) Equals(other Expression) bool
func (*DynamicParameter) GetType ¶
func (dp *DynamicParameter) GetType() types.Type
func (*DynamicParameter) IsScalar ¶
func (dp *DynamicParameter) IsScalar() bool
func (*DynamicParameter) String ¶
func (dp *DynamicParameter) String() string
func (*DynamicParameter) ToProto ¶
func (dp *DynamicParameter) ToProto() *proto.Expression
func (*DynamicParameter) ToProtoFuncArg ¶
func (dp *DynamicParameter) ToProtoFuncArg() *proto.FunctionArgument
func (*DynamicParameter) Visit ¶
func (dp *DynamicParameter) Visit(visit VisitFunc) Expression
type ExprBuilder ¶
type ExprBuilder struct {
Reg ExtensionRegistry
BaseSchema *types.RecordType
// contains filtered or unexported fields
}
ExprBuilder is the parent context for all the expression builders. It maintains a pointer to an extension registry and, optionally, a pointer to a base input schema. This allows less verbose expression building as it isn't necessary to pass these to every `New*` function to construct the expressions.
This is intended to be used like:
b := expr.ExprBuilder{
Reg: ...,
BaseSchema: ...,
}
e, err := b.ScalarFunc(fnID, options...).Args(
b.RootRef(expr.NewStructFieldRef(1)),
b.ScalarFunc(fn2ID, options2...).Args(
b.Wrap(expr.NewLiteral(int32(5), false /* nullable type */)),
b.RootRef(expr.NewStructFieldRef(2))))
See the unit tests for additional examples / constructs.
func (*ExprBuilder) AggFunc ¶
func (e *ExprBuilder) AggFunc( id extensions.ID, opts ...*types.FunctionOption, ) *aggregateFuncBuilder
AggFunc returns a builder for the aggregate function represented by the passed in ID and options. Other properties such as Arguments, aggregation phase, invocation, sort fields, etc. can be then added via individual methods on the returned builder. Validity of the ID, argument types and number of arguments will be checked at the point that the Build method is called to construct the final expression and will return an error if invalid.
The extension registry inside of ExprBuilder will be used to resolve the ID, but only at the point at which Build is called. Therefore this can be called before actually loading the extensions as long as the extension identified by the ID is loaded into the registry *before* `Build` is called.
func (*ExprBuilder) Cast ¶
func (e *ExprBuilder) Cast(from Builder, to types.Type) *castBuilder
Cast returns a builder for constructing a Cast expression. The failure behavior can be specified by calling FailBehavior before calling Build.
func (*ExprBuilder) DynamicParam ¶
func (e *ExprBuilder) DynamicParam(outputType types.Type, paramRef uint32) *dynamicParamBuilder
DynamicParam returns a builder for constructing a DynamicParameter expression. The paramRef identifies the parameter binding in the plan.
func (*ExprBuilder) Enum ¶
func (e *ExprBuilder) Enum(val string) enumWrapper
Enum wraps a string representing an Enum argument to a function being built.
func (*ExprBuilder) Expression ¶
func (e *ExprBuilder) Expression(expr Expression) exprWrapper
Expression returns a wrapped expression that can be passed as an argument to any of the other expression builders such as ScalarFunc.Args.
func (*ExprBuilder) Lambda ¶
func (e *ExprBuilder) Lambda(params *types.StructType, body Builder) *lambdaBuilder
Lambda returns a builder for constructing a Lambda expression with the given parameters.
When building nested lambdas (e.g., a function that takes a lambda argument which itself references outer lambda parameters), the ExprBuilder maintains a context stack that allows inner lambdas to validate stepsOut references against outer lambda parameters.
func (*ExprBuilder) LambdaParamRef ¶
func (e *ExprBuilder) LambdaParamRef(ref StructFieldRef, stepsOut uint32) *lambdaParamRefBuilder
LambdaParamRef constructs a field reference to a lambda parameter.
Lambda parameters are always a StructType, so this method takes a StructFieldRef to specify which parameter (field) to reference.
The stepsOut parameter specifies how many lambda scopes to traverse outward from the current lambda to find the target parameter (0 = current lambda, 1 = outer lambda, etc.).
The Build method validates the stepsOut value and field index against the available lambda context, and resolves the reference type automatically.
func (*ExprBuilder) Literal ¶
func (e *ExprBuilder) Literal(l Literal) exprWrapper
Literal returns a wrapped literal that can be passed as an argument to any of the other expression builders such as ScalarFunc.Args.
func (*ExprBuilder) Ref ¶
func (e *ExprBuilder) Ref(root RootRefType, ref Reference) *fieldRefBuilder
Ref constructs a field reference with the provided root and reference type. When `Build` is called on the returned builder, the `BaseSchema` in ExprBuilder will be used to resolve the type of the expression if relevant (such as a StructFieldRef/ListRef/MapKeyRef).
func (*ExprBuilder) RootRef ¶
func (e *ExprBuilder) RootRef(ref Reference) *fieldRefBuilder
RootRef is a convenience method equivalent to calling ExprBuilder.Ref with `expr.RootReference` as the first argument.
func (*ExprBuilder) ScalarFunc ¶
func (e *ExprBuilder) ScalarFunc( id extensions.ID, opts ...*types.FunctionOption, ) *scalarFuncBuilder
ScalarFunc returns a builder for the scalar function represented by the passed in ID and options. Use the Args method to add arguments to this builder. Validity of the ID, argument types and number of arguments will be checked at the point that the Build method is called to construct the final expression and will return an error if invalid.
The extension registry inside of ExprBuilder will be used to resolve the ID, but only at the point at which Build is called. Therefore this can be called before actually loading the extensions as long as the extension identified by the ID is loaded into the registry *before* `Build` is called.
func (*ExprBuilder) WindowFunc ¶
func (e *ExprBuilder) WindowFunc( id extensions.ID, opts ...*types.FunctionOption, ) *windowFuncBuilder
WindowFunc returns a builder for the window function represented by the passed in ID and options. Other properties such as Arguments, aggregation phase, invocation, sort fields, etc. can be then added via individual methods on the returned builder. Validity of the ID, argument types and number of arguments will be checked at the point that the Build method is called to construct the final expression and will return an error if invalid.
The extension registry inside of ExprBuilder will be used to resolve the ID, but only at the point at which Build is called. Therefore this can be called before actually loading the extensions as long as the extension identified by the ID is loaded into the registry *before* `Build` is called.
func (*ExprBuilder) Wrap ¶
func (e *ExprBuilder) Wrap(l Literal, err error) exprWrapper
Wrap is like Literal or Expression but allows propagating an error (such as when calling expr.NewLiteral) that will bubble up when attempting to build an expression so it doesn't get swallowed or force a panic.
type Expression ¶
type Expression interface {
// an Expression can also be a function argument
types.FuncArg
// an expression can also be the root of a reference
RootRefType
IsScalar() bool
// GetType returns the output type of this expression
GetType() types.Type
// ToProto converts this Expression and its arguments
// to the equivalent Protobuf objects.
ToProto() *proto.Expression
// Equals returns true if this expression and all of its
// arguments and their children etc. are equal to the passed
// in Expression.
Equals(Expression) bool
// Visit invokes the passed visit function for each child of the
// expression. The visit function can return its input expression
// as-is with no changes, or it can construct and return a
// replacement expression. If any children have been replaced, Visit
// will construct and return a new instance of this expression using
// the new children. Callers can use the Visit method to traverse
// and potentially rewrite the expression tree, in either pre or post
// order. Here is a pre-order example:
//
// func preOrderVisit(e Expression) Expression {
// // Replace some scalar function, leave everything else
// // as-is. This check is before the call to Visit, so
// // it's a pre-order traversal
// if f, ok := e.(*ScalarFunction); ok {
// return &ScalarFunction{
// ID: ExtID{URN: "some other urn", Name: "some other func"},
// Args: f.Args,
// Options: f.Options,
// OutputType: f.OutputType,
// }
// }
// return e.Visit(preOrderVisit)
// }
// newExpr := preOrderVisit(oldExpr)
Visit(VisitFunc) Expression
}
Expression can be one of many different things as a generalized expression. It could be:
- A literal
- A Field Reference Selection
- A Scalar Function expression
- A Window Function expression
- An If-Then statement
- A Switch Expression
- A Singular Or List
- A Multiple Or List
- A Cast expression
- A Subquery
- A Nested expression
- A Dynamic Parameter
Example (ScalarFunction) ¶
package main
import (
"fmt"
"strings"
"github.com/substrait-io/substrait-go/v8/expr"
ext "github.com/substrait-io/substrait-go/v8/extensions"
"github.com/substrait-io/substrait-go/v8/types"
proto "github.com/substrait-io/substrait-protobuf/go/substraitpb"
"google.golang.org/protobuf/encoding/protojson"
pb "google.golang.org/protobuf/proto"
)
const sampleYAML = `---
urn: extension:io.substrait:functions_arithmetic
scalar_functions:
-
name: "add"
description: "Add two values."
impls:
- args:
- name: x
value: i8
- name: y
value: i8
options:
overflow:
values: [ SILENT, SATURATE, ERROR ]
return: i8
`
var collection ext.Collection
func init() {
err := collection.Load("https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml", strings.NewReader(sampleYAML))
if err != nil {
panic(err)
}
}
func main() {
// define extensions with no plan for now
const planExt = `{
"extensionUrns": [
{
"extensionUrnAnchor": 1,
"urn": "extension:io.substrait:functions_arithmetic"
}
],
"extensions": [
{
"extensionFunction": {
"extensionUrnReference": 1,
"functionAnchor": 2,
"name": "add:i32_i32"
}
}
],
"relations": []
}`
var plan proto.Plan
if err := protojson.Unmarshal([]byte(planExt), &plan); err != nil {
panic(err)
}
extSet, err := ext.GetExtensionSet(&plan, &collection)
if err != nil {
panic(err)
}
// json proto to represent of add(field_ref(0), float64(10))
const scalarFunction = `{
"scalarFunction": {
"functionReference": 2,
"outputType": {"i32": {}},
"arguments": [
{"value": {"selection": {
"rootReference": {},
"directReference": {"structField": {"field": 0}}}}},
{"value": {"literal": {"fp64": 10}}}
]
}
}`
var exprProto proto.Expression
if err := protojson.Unmarshal([]byte(scalarFunction), &exprProto); err != nil {
panic(err)
}
reg := expr.NewExtensionRegistry(extSet, &collection)
// convert from protobuf to Expression!
fromProto, err := expr.ExprFromProto(&exprProto, nil, reg)
if err != nil {
panic(err)
}
// manually define the entire expression instead of going through
// having to construct the protobuf
const substraitext = `extension:io.substrait:functions_arithmetic`
var addVariant = ext.NewScalarFuncVariant(ext.ID{URN: substraitext, Name: "add:i32_i32"})
var ex expr.Expression
refArg, _ := expr.NewRootFieldRef(expr.NewStructFieldRef(0), types.NewRecordTypeFromTypes([]types.Type{&types.Int32Type{}}))
ex, _ = expr.NewCustomScalarFunc(reg, addVariant, &types.Int32Type{}, nil,
refArg, expr.NewPrimitiveLiteral(float64(10), false))
// call ToProto to convert our manual expression to proto.Expression
toProto := ex.ToProto()
// output some info!
// print string represention of the expression
fmt.Println(fromProto)
// print the string representation of our
// manually constructed expression
fmt.Println(ex)
// verify that the Equals methods work recursively
fmt.Println(ex.Equals(fromProto))
// confirm our manually constructed expression is the same
// as the one we got from protojson
fmt.Println(pb.Equal(&exprProto, toProto))
}
Output: add(.field(0), fp64(10)) => i32 add(.field(0) => i32, fp64(10)) => i32 true true
func ExprFromProto ¶
func ExprFromProto(e *proto.Expression, baseSchema *types.RecordType, reg ExtensionRegistry) (Expression, error)
func MustExpr ¶
func MustExpr(e Expression, err error) Expression
type ExpressionReference ¶
type ExpressionReference struct {
OutputNames []string
// contains filtered or unexported fields
}
func NewExpressionReference ¶
func NewExpressionReference(names []string, ex Expression) ExpressionReference
func NewMeasureReference ¶
func NewMeasureReference(names []string, measure *AggregateFunction) ExpressionReference
func (*ExpressionReference) GetExpr ¶
func (er *ExpressionReference) GetExpr() Expression
func (*ExpressionReference) GetMeasure ¶
func (er *ExpressionReference) GetMeasure() *AggregateFunction
func (*ExpressionReference) SetExpr ¶
func (er *ExpressionReference) SetExpr(ex Expression)
func (*ExpressionReference) SetMeasure ¶
func (er *ExpressionReference) SetMeasure(m *AggregateFunction)
func (*ExpressionReference) ToProto ¶
func (er *ExpressionReference) ToProto() *proto.ExpressionReference
type Extended ¶
type Extended struct {
Version *types.Version
Extensions extensions.Set
ReferredExpr []ExpressionReference
BaseSchema types.NamedStruct
AdvancedExts *extensions.AdvancedExtension
ExpectedTypeURLs []string
// contains filtered or unexported fields
}
func ExtendedFromProto ¶
func ExtendedFromProto(ex *proto.ExtendedExpression, c *extensions.Collection) (*Extended, error)
func (*Extended) ToProto ¶
func (ex *Extended) ToProto() *proto.ExtendedExpression
type ExtensionRegistry ¶
type ExtensionRegistry struct {
extensions.Set
// contains filtered or unexported fields
}
ExtensionRegistry provides functionality to resolve extension references and handle subquery expressions. It combines an extensions.Set for looking up extension definitions with a Collection for extension metadata.
func NewEmptyExtensionRegistry ¶
func NewEmptyExtensionRegistry(c *extensions.Collection) ExtensionRegistry
NewEmptyExtensionRegistry creates an empty registry useful starting from scratch.
func NewExtensionRegistry ¶
func NewExtensionRegistry(extSet extensions.Set, c *extensions.Collection) ExtensionRegistry
NewExtensionRegistry creates a new registry. If you have an existing plan you can use GetExtensionSet() to populate an extensions.Set.
func (*ExtensionRegistry) ExtensionsToProto ¶
func (e *ExtensionRegistry) ExtensionsToProto() ([]*extensionspb.SimpleExtensionURN, []*extensionspb.SimpleExtensionDeclaration)
ExtensionsToProto returns the URNs and declarations from the extension set using the registry's collection.
func (*ExtensionRegistry) LookupAggregateFunction ¶
func (e *ExtensionRegistry) LookupAggregateFunction(anchor uint32) (*extensions.AggregateFunctionVariant, bool)
LookupAggregateFunction returns an AggregateFunctionVariant associated with a previously used function's anchor.
func (*ExtensionRegistry) LookupScalarFunction ¶
func (e *ExtensionRegistry) LookupScalarFunction(anchor uint32) (*extensions.ScalarFunctionVariant, bool)
LookupScalarFunction returns a ScalarFunctionVariant associated with a previously used function's anchor.
func (*ExtensionRegistry) LookupType ¶
func (e *ExtensionRegistry) LookupType(anchor uint32) (extensions.Type, bool)
func (*ExtensionRegistry) LookupTypeVariation ¶
func (e *ExtensionRegistry) LookupTypeVariation(anchor uint32) (extensions.TypeVariation, bool)
func (*ExtensionRegistry) LookupWindowFunction ¶
func (e *ExtensionRegistry) LookupWindowFunction(anchor uint32) (*extensions.WindowFunctionVariant, bool)
LookupWindowFunction returns a WindowFunctionVariant associated with a previously used function's anchor.
func (*ExtensionRegistry) SetSubqueryConverter ¶
func (e *ExtensionRegistry) SetSubqueryConverter(converter subqueryConverter)
SetSubqueryConverter allows the plan package to inject a subquery converter. This is an internal function used to break the dependency cycle between expr and plan packages.
type FieldReference ¶
type FieldReference struct {
Reference Reference
Root RootRefType
// contains filtered or unexported fields
}
func FieldReferenceFromProto ¶
func FieldReferenceFromProto(p *proto.Expression_FieldReference, baseSchema *types.RecordType, reg ExtensionRegistry) (*FieldReference, error)
func NewFieldRef ¶
func NewFieldRef(root RootRefType, ref Reference, baseSchema *types.RecordType) (*FieldReference, error)
func NewFieldRefFromType ¶
func NewFieldRefFromType(root RootRefType, ref Reference, t types.Type) (*FieldReference, error)
NewFieldRefFromType creates a new field reference with a specific known type. Prefer using NewFieldRef.
func NewRootFieldRef ¶
func NewRootFieldRef(ref Reference, baseSchema *types.RecordType) (*FieldReference, error)
func NewRootFieldRefFromType ¶
func NewRootFieldRefFromType(ref Reference, t types.Type) (*FieldReference, error)
NewRootFieldRefFromType creates a new field reference with a specific known type. Prefer using NewRootFieldRef.
func (*FieldReference) Equals ¶
func (f *FieldReference) Equals(rhs Expression) bool
func (*FieldReference) GetType ¶
func (f *FieldReference) GetType() types.Type
func (*FieldReference) IsScalar ¶
func (*FieldReference) IsScalar() bool
func (*FieldReference) String ¶
func (f *FieldReference) String() string
func (*FieldReference) ToProto ¶
func (f *FieldReference) ToProto() *proto.Expression
func (*FieldReference) ToProtoFieldRef ¶
func (f *FieldReference) ToProtoFieldRef() *proto.Expression_FieldReference
func (*FieldReference) ToProtoFuncArg ¶
func (f *FieldReference) ToProtoFuncArg() *proto.FunctionArgument
func (*FieldReference) Visit ¶
func (f *FieldReference) Visit(v VisitFunc) Expression
type FollowingBound ¶
type FollowingBound int64
func (FollowingBound) String ¶
func (fb FollowingBound) String() string
func (FollowingBound) ToProto ¶
func (fb FollowingBound) ToProto() *proto.Expression_WindowFunction_Bound
type FuncArgBuilder ¶
type FunctionInvocation ¶
type FunctionInvocation interface {
CompoundName() string
ID() extensions.ID
GetOptions() []*types.FunctionOption
GetArgTypes() []types.Type
}
type IfThen ¶
type IfThen struct {
// contains filtered or unexported fields
}
func NewIfThen ¶
func NewIfThen(firstIf IfThenPair, elseClause Expression, elsifs ...IfThenPair) (*IfThen, error)
NewIfThen constructs a new IfThen expression, verifying it is valid.
elseClause should not be nil as there is a required default via the else. The constructed expression would be interpreted as this pseudocode:
if <firstIf.If> then <firstIf.Then> foreach e in elsifs: if <e.If> then <e.Then> endforeach else <elseClause>
If elseClause is nil or all of the result expressions do not have the same result type, an error will be returned.
func (*IfThen) Else ¶
func (ex *IfThen) Else() Expression
func (*IfThen) Equals ¶
func (ex *IfThen) Equals(other Expression) bool
func (*IfThen) IfPair ¶
func (ex *IfThen) IfPair(i int) IfThenPair
IfPair returns the IfThenPair for the given index. It is not bounds-checked
func (*IfThen) NIfs ¶
NIfs returns the number of If/then pairs are in this expression before the else clause. It should always be at least 1
func (*IfThen) ToProto ¶
func (ex *IfThen) ToProto() *proto.Expression
func (*IfThen) ToProtoFuncArg ¶
func (ex *IfThen) ToProtoFuncArg() *proto.FunctionArgument
func (*IfThen) Visit ¶
func (ex *IfThen) Visit(visit VisitFunc) Expression
type IfThenPair ¶
type IfThenPair struct {
If Expression
Then Expression
}
type IntervalCompoundLiteral ¶
type IntervalCompoundLiteral struct {
Years int32
Months int32
Days int32
Seconds int32
SubSeconds int64
SubSecondPrecision types.TimePrecision
Nullability types.Nullability
}
IntervalCompoundLiteral creates an interval compound literal
func (IntervalCompoundLiteral) Equals ¶
func (m IntervalCompoundLiteral) Equals(rhs Expression) bool
func (IntervalCompoundLiteral) GetType ¶
func (m IntervalCompoundLiteral) GetType() types.Type
func (IntervalCompoundLiteral) IsScalar ¶
func (IntervalCompoundLiteral) IsScalar() bool
func (IntervalCompoundLiteral) String ¶
func (m IntervalCompoundLiteral) String() string
func (IntervalCompoundLiteral) ToProto ¶
func (m IntervalCompoundLiteral) ToProto() *proto.Expression
func (IntervalCompoundLiteral) ToProtoFuncArg ¶
func (m IntervalCompoundLiteral) ToProtoFuncArg() *proto.FunctionArgument
func (IntervalCompoundLiteral) ToProtoLiteral ¶
func (m IntervalCompoundLiteral) ToProtoLiteral() *proto.Expression_Literal
func (IntervalCompoundLiteral) ValueString ¶
func (m IntervalCompoundLiteral) ValueString() string
func (IntervalCompoundLiteral) Visit ¶
func (m IntervalCompoundLiteral) Visit(VisitFunc) Expression
type IntervalYearToMonthLiteral ¶
type IntervalYearToMonthLiteral struct {
Years int32
Months int32
Nullability types.Nullability
}
IntervalYearToMonthLiteral implements Literal interface for interval year to month type
func (IntervalYearToMonthLiteral) Equals ¶
func (m IntervalYearToMonthLiteral) Equals(rhs Expression) bool
func (IntervalYearToMonthLiteral) GetType ¶
func (m IntervalYearToMonthLiteral) GetType() types.Type
func (IntervalYearToMonthLiteral) IsScalar ¶
func (IntervalYearToMonthLiteral) IsScalar() bool
func (IntervalYearToMonthLiteral) String ¶
func (m IntervalYearToMonthLiteral) String() string
func (IntervalYearToMonthLiteral) ToProto ¶
func (m IntervalYearToMonthLiteral) ToProto() *proto.Expression
func (IntervalYearToMonthLiteral) ToProtoFuncArg ¶
func (m IntervalYearToMonthLiteral) ToProtoFuncArg() *proto.FunctionArgument
func (IntervalYearToMonthLiteral) ToProtoLiteral ¶
func (m IntervalYearToMonthLiteral) ToProtoLiteral() *proto.Expression_Literal
func (IntervalYearToMonthLiteral) ValueString ¶
func (m IntervalYearToMonthLiteral) ValueString() string
func (IntervalYearToMonthLiteral) Visit ¶
func (m IntervalYearToMonthLiteral) Visit(VisitFunc) Expression
type Lambda ¶
type Lambda struct {
Parameters *types.StructType // The formal lambda parameters, required to have NULLABILITY_REQUIRED
Body Expression
}
Lambda represents a lambda expression with parameters and a body.
func (*Lambda) Equals ¶
func (l *Lambda) Equals(other Expression) bool
func (*Lambda) ToProto ¶
func (l *Lambda) ToProto() *proto.Expression
func (*Lambda) ToProtoFuncArg ¶
func (l *Lambda) ToProtoFuncArg() *proto.FunctionArgument
func (*Lambda) Visit ¶
func (l *Lambda) Visit(visit VisitFunc) Expression
type LambdaParameterReference ¶
type LambdaParameterReference struct {
StepsOut uint32
}
LambdaParameterReference is a root reference type for accessing lambda parameters within a lambda body expression. StepsOut indicates how many lambda boundaries to traverse up (0 = current lambda, 1 = outer lambda, etc.)
type ListElementRef ¶
type ListElementRef struct {
Offset int32
Child ReferenceSegment
}
func NewListElemRef ¶
func NewListElemRef(offset int32) *ListElementRef
func (*ListElementRef) Equals ¶
func (r *ListElementRef) Equals(rhs ReferenceSegment) bool
func (*ListElementRef) GetChild ¶
func (r *ListElementRef) GetChild() ReferenceSegment
func (*ListElementRef) String ¶
func (r *ListElementRef) String() string
func (*ListElementRef) ToProto ¶
func (r *ListElementRef) ToProto() *proto.Expression_ReferenceSegment
type ListExpr ¶
type ListExpr struct {
Nullable bool
TypeVariationRef uint32
Values []Expression
}
func NewListExpr ¶
func NewListExpr(nullable bool, vals ...Expression) *ListExpr
func (*ListExpr) Equals ¶
func (ex *ListExpr) Equals(other Expression) bool
func (*ListExpr) IsNullable ¶
func (*ListExpr) ToProto ¶
func (ex *ListExpr) ToProto() *proto.Expression
func (*ListExpr) ToProtoFuncArg ¶
func (ex *ListExpr) ToProtoFuncArg() *proto.FunctionArgument
func (*ListExpr) TypeVariation ¶
func (*ListExpr) Visit ¶
func (ex *ListExpr) Visit(visit VisitFunc) Expression
type ListLiteral ¶
type ListLiteral = NestedLiteral[ListLiteralValue]
Convenience names so that there is StructLiteral, ListLiteral and MapLiteral
func NewEmptyListLiteral ¶
func NewEmptyListLiteral(t types.Type, nullable bool) *ListLiteral
NewEmptyListLiteral creates an empty list literal of the type and marks the type as nullable or not.
type ListLiteralValue ¶
type ListLiteralValue []Literal
ListLiteralValue is a slice of other literals
type Literal ¶
type Literal interface {
// Literals are also Function arguments
types.FuncArg
RootRefType
fmt.Stringer
IsScalar() bool
// GetType returns the full Type of the literal value
GetType() types.Type
// Equals only returns true if the rhs is a literal of the exact
// same type and value.
Equals(Expression) bool
ToProto() *proto.Expression
ToProtoLiteral() *proto.Expression_Literal
Visit(VisitFunc) Expression
// ValueString returns a human presentable representation of just the literal's value.
ValueString() string
}
Literal represents a specific literal of some type which could also be a typed null or a nested type like a struct/map/list.
An empty map/empty list will have len(value) == 0
func LiteralFromProto ¶
func LiteralFromProto(l *proto.Expression_Literal) Literal
LiteralFromProto constructs the appropriate Literal struct from a protobuf message.
func NewLiteral ¶
func NewNestedLiteral ¶
func NewNestedLiteral[T StructLiteralValue | MapLiteralValue | ListLiteralValue](val T, nullable bool) Literal
NewNestedLiteral constructs a new literal value and marks whether the type should be considered nullable. This assumes that the passed in value is not empty, so len(v) MUST be > 0.
For an Empty Map literal or an empty List literal, you need to use the corresponding NewEmptyMapLiteral and NewEmptyListLiteral functions which take the Type of the empty literal as an argument.
func NewPrecisionTimeLiteral ¶
func NewPrecisionTimeLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
NewPrecisionTimeLiteral creates a new PrecisionTime from an integer value, representing time since midnight, in the specified precision (nanoseconds to seconds).
func NewPrecisionTimestampLiteral ¶
func NewPrecisionTimestampLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
NewPrecisionTimestampLiteral creates a new PrecisionTimestamp from an integer value, representing time since the unix epoch, in the specified precision (nanoseconds to seconds).
func NewPrecisionTimestampTzLiteral ¶
func NewPrecisionTimestampTzLiteral(value int64, precision types.TimePrecision, n types.Nullability) Literal
NewPrecisionTimestampTzLiteral it takes timestamp value which is in specified precision and nullable property (n) and returns a PrecisionTimestampTz Literal
func NewPrimitiveLiteral ¶
type MapExpr ¶
type MapExpr struct {
Nullable bool
TypeVariationRef uint32
KeyValues []struct{ Key, Value Expression }
}
func (*MapExpr) Equals ¶
func (ex *MapExpr) Equals(other Expression) bool
func (*MapExpr) IsNullable ¶
func (*MapExpr) ToProto ¶
func (ex *MapExpr) ToProto() *proto.Expression
func (*MapExpr) ToProtoFuncArg ¶
func (ex *MapExpr) ToProtoFuncArg() *proto.FunctionArgument
func (*MapExpr) TypeVariation ¶
func (*MapExpr) Visit ¶
func (ex *MapExpr) Visit(visit VisitFunc) Expression
type MapKeyRef ¶
type MapKeyRef struct {
MapKey Literal
Child ReferenceSegment
}
func NewMapKeyRef ¶
func (*MapKeyRef) Equals ¶
func (r *MapKeyRef) Equals(rhs ReferenceSegment) bool
func (*MapKeyRef) GetChild ¶
func (r *MapKeyRef) GetChild() ReferenceSegment
func (*MapKeyRef) ToProto ¶
func (r *MapKeyRef) ToProto() *proto.Expression_ReferenceSegment
type MapLiteral ¶
type MapLiteral struct {
Value MapLiteralValue
Type types.Type
}
MapLiteral is represented as a slice of Key/Value structs consisting of other literals.
func NewEmptyMapLiteral ¶
func NewEmptyMapLiteral(key, val types.Type, nullable bool) *MapLiteral
NewEmptyMapLiteral creates an empty map literal of the provided key/value types and marks the type as nullable or not.
func (*MapLiteral) Equals ¶
func (t *MapLiteral) Equals(rhs Expression) bool
func (*MapLiteral) GetType ¶
func (t *MapLiteral) GetType() types.Type
func (*MapLiteral) IsScalar ¶
func (*MapLiteral) IsScalar() bool
func (*MapLiteral) String ¶
func (t *MapLiteral) String() string
func (*MapLiteral) ToProto ¶
func (t *MapLiteral) ToProto() *proto.Expression
func (*MapLiteral) ToProtoFuncArg ¶
func (t *MapLiteral) ToProtoFuncArg() *proto.FunctionArgument
func (*MapLiteral) ToProtoLiteral ¶
func (t *MapLiteral) ToProtoLiteral() *proto.Expression_Literal
func (*MapLiteral) ValueString ¶
func (t *MapLiteral) ValueString() string
func (*MapLiteral) Visit ¶
func (t *MapLiteral) Visit(VisitFunc) Expression
type MapLiteralValue ¶
Easy type aliases for multi-value types that also saves us having to create new types / new objects at runtime when getting them from protobuf.
type MapSelectKind ¶
type MapSelectKind int8
const ( MapSelectKey MapSelectKind = iota MapSelectExpr )
type MaskExpression ¶
type MaskExpression struct {
// contains filtered or unexported fields
}
MaskExpression is a reference that takes an existing subtype and selectively removes fields from it. For example, one might initially have an inner struct with 100 fields, but a particular operation only needs to interact with 2 of those 100 fields. In this situation, one would use a mask expression to eliminate the 98 fields that are not relevant to the rest of the operations pipeline.
Note that this does not fundamentally alter the structure of data beyond the elimination of unnecessary elements.
func MaskExpressionFromProto ¶
func MaskExpressionFromProto(p *proto.Expression_MaskExpression) *MaskExpression
func (*MaskExpression) MaintainSingularStruct ¶
func (e *MaskExpression) MaintainSingularStruct() bool
func (*MaskExpression) Select ¶
func (e *MaskExpression) Select() MaskStructSelect
func (*MaskExpression) ToProto ¶
func (e *MaskExpression) ToProto() *proto.Expression_MaskExpression
type MaskListElement ¶
type MaskListElement proto.Expression_MaskExpression_ListSelect_ListSelectItem_ListElement
func (*MaskListElement) GetField ¶
func (m *MaskListElement) GetField() int32
func (*MaskListElement) ToProto ¶
func (m *MaskListElement) ToProto() *proto.Expression_MaskExpression_ListSelect_ListSelectItem
type MaskListSelect ¶
type MaskListSelect struct {
// contains filtered or unexported fields
}
func (*MaskListSelect) Child ¶
func (m *MaskListSelect) Child() MaskSelect
func (*MaskListSelect) Selection ¶
func (m *MaskListSelect) Selection() []MaskListSelectItem
func (*MaskListSelect) ToProto ¶
func (m *MaskListSelect) ToProto() *proto.Expression_MaskExpression_Select
type MaskListSelectItem ¶
type MaskListSelectItem interface {
ToProto() *proto.Expression_MaskExpression_ListSelect_ListSelectItem
}
type MaskListSlice ¶
type MaskListSlice proto.Expression_MaskExpression_ListSelect_ListSelectItem_ListSlice
func (*MaskListSlice) GetBounds ¶
func (m *MaskListSlice) GetBounds() (start, end int32)
func (*MaskListSlice) ToProto ¶
func (m *MaskListSlice) ToProto() *proto.Expression_MaskExpression_ListSelect_ListSelectItem
type MaskMapSelect ¶
type MaskMapSelect struct {
// contains filtered or unexported fields
}
func (*MaskMapSelect) Child ¶
func (m *MaskMapSelect) Child() MaskSelect
func (*MaskMapSelect) Key ¶
func (m *MaskMapSelect) Key() string
func (*MaskMapSelect) KeyKind ¶
func (m *MaskMapSelect) KeyKind() MapSelectKind
func (*MaskMapSelect) ToProto ¶
func (m *MaskMapSelect) ToProto() *proto.Expression_MaskExpression_Select
type MaskSelect ¶
type MaskSelect interface {
ToProto() *proto.Expression_MaskExpression_Select
}
type MaskStructItem ¶
type MaskStructItem struct {
// contains filtered or unexported fields
}
func (*MaskStructItem) Child ¶
func (m *MaskStructItem) Child() MaskSelect
func (*MaskStructItem) Field ¶
func (m *MaskStructItem) Field() int32
func (*MaskStructItem) ToProto ¶
func (m *MaskStructItem) ToProto() *proto.Expression_MaskExpression_StructItem
type MaskStructSelect ¶
type MaskStructSelect []MaskStructItem
func (MaskStructSelect) ToProto ¶
func (m MaskStructSelect) ToProto() *proto.Expression_MaskExpression_Select
type MultiOrList ¶
type MultiOrList struct {
Value []Expression
Options [][]Expression
}
func (*MultiOrList) Equals ¶
func (ex *MultiOrList) Equals(other Expression) bool
func (*MultiOrList) GetType ¶
func (ex *MultiOrList) GetType() types.Type
func (*MultiOrList) IsScalar ¶
func (ex *MultiOrList) IsScalar() bool
func (*MultiOrList) String ¶
func (ex *MultiOrList) String() string
func (*MultiOrList) ToProto ¶
func (ex *MultiOrList) ToProto() *proto.Expression
func (*MultiOrList) ToProtoFuncArg ¶
func (ex *MultiOrList) ToProtoFuncArg() *proto.FunctionArgument
func (*MultiOrList) Visit ¶
func (ex *MultiOrList) Visit(visit VisitFunc) Expression
type NestedExpr ¶
type NestedExpr interface {
Expression
IsNullable() bool
TypeVariation() uint32
}
type NestedLiteral ¶
NestedLiteral is either a Struct or List literal, both of which are represented as a slice of other literals.
func (*NestedLiteral[T]) Equals ¶
func (t *NestedLiteral[T]) Equals(rhs Expression) bool
func (*NestedLiteral[T]) GetType ¶
func (t *NestedLiteral[T]) GetType() types.Type
func (*NestedLiteral[T]) IsScalar ¶
func (*NestedLiteral[T]) IsScalar() bool
func (*NestedLiteral[T]) String ¶
func (t *NestedLiteral[T]) String() string
func (*NestedLiteral[T]) ToProto ¶
func (t *NestedLiteral[T]) ToProto() *proto.Expression
func (*NestedLiteral[T]) ToProtoFuncArg ¶
func (t *NestedLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
func (*NestedLiteral[T]) ToProtoLiteral ¶
func (t *NestedLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
func (*NestedLiteral[T]) ValueString ¶
func (t *NestedLiteral[T]) ValueString() string
func (*NestedLiteral[T]) Visit ¶
func (t *NestedLiteral[T]) Visit(VisitFunc) Expression
type NullLiteral ¶
A NullLiteral is a typed null, so it just contains its type with no value
func NewNullLiteral ¶
func NewNullLiteral(t types.Type) *NullLiteral
func (*NullLiteral) Equals ¶
func (n *NullLiteral) Equals(rhs Expression) bool
func (*NullLiteral) GetType ¶
func (n *NullLiteral) GetType() types.Type
func (*NullLiteral) IsScalar ¶
func (*NullLiteral) IsScalar() bool
func (*NullLiteral) String ¶
func (n *NullLiteral) String() string
func (*NullLiteral) ToProto ¶
func (n *NullLiteral) ToProto() *proto.Expression
func (*NullLiteral) ToProtoFuncArg ¶
func (n *NullLiteral) ToProtoFuncArg() *proto.FunctionArgument
func (*NullLiteral) ToProtoLiteral ¶
func (n *NullLiteral) ToProtoLiteral() *proto.Expression_Literal
func (*NullLiteral) ValueString ¶
func (n *NullLiteral) ValueString() string
func (*NullLiteral) Visit ¶
func (n *NullLiteral) Visit(VisitFunc) Expression
type OuterReference ¶
type OuterReference uint32
TODO (#198): represent this as a struct to better match format of LambdaParamterReference
type PrecedingBound ¶
type PrecedingBound int64
func (PrecedingBound) String ¶
func (fb PrecedingBound) String() string
func (PrecedingBound) ToProto ¶
func (fb PrecedingBound) ToProto() *proto.Expression_WindowFunction_Bound
type PrimitiveLiteral ¶
type PrimitiveLiteral[T PrimitiveLiteralValue] struct { Value T Type types.Type }
PrimitiveLiteral represents a non-nested, non-null literal value which can be compared easily using ==
func NewFixedCharLiteral ¶
func (*PrimitiveLiteral[T]) Equals ¶
func (t *PrimitiveLiteral[T]) Equals(rhs Expression) bool
func (*PrimitiveLiteral[T]) GetType ¶
func (t *PrimitiveLiteral[T]) GetType() types.Type
func (*PrimitiveLiteral[T]) IsScalar ¶
func (*PrimitiveLiteral[T]) IsScalar() bool
func (*PrimitiveLiteral[T]) IsoValueString ¶
func (t *PrimitiveLiteral[T]) IsoValueString() string
func (*PrimitiveLiteral[T]) String ¶
func (t *PrimitiveLiteral[T]) String() string
func (*PrimitiveLiteral[T]) ToProto ¶
func (t *PrimitiveLiteral[T]) ToProto() *proto.Expression
func (*PrimitiveLiteral[T]) ToProtoFuncArg ¶
func (t *PrimitiveLiteral[T]) ToProtoFuncArg() *proto.FunctionArgument
func (*PrimitiveLiteral[T]) ToProtoLiteral ¶
func (t *PrimitiveLiteral[T]) ToProtoLiteral() *proto.Expression_Literal
func (*PrimitiveLiteral[T]) ValueString ¶
func (t *PrimitiveLiteral[T]) ValueString() string
func (*PrimitiveLiteral[T]) Visit ¶
func (t *PrimitiveLiteral[T]) Visit(VisitFunc) Expression
type PrimitiveLiteralValue ¶
type PrimitiveLiteralValue interface {
bool | int8 | int16 | ~int32 | ~int64 | float32 | float64 | ~string
}
PrimitiveLiteralValue is a type constraint that represents any of the non-nested literal types which are also easily comparable via ==
type ProtoLiteral ¶
ProtoLiteral is a literal that is represented using its protobuf message type such as a Decimal or UserDefinedType.
func (*ProtoLiteral) Equals ¶
func (t *ProtoLiteral) Equals(rhs Expression) bool
func (*ProtoLiteral) GetType ¶
func (t *ProtoLiteral) GetType() types.Type
func (*ProtoLiteral) IsScalar ¶
func (*ProtoLiteral) IsScalar() bool
func (*ProtoLiteral) IsoValueString ¶
func (t *ProtoLiteral) IsoValueString() string
IsoValueString handles precision timestamp and interval literals to return a string in ISO 8601 format
func (*ProtoLiteral) String ¶
func (t *ProtoLiteral) String() string
func (*ProtoLiteral) ToProto ¶
func (t *ProtoLiteral) ToProto() *proto.Expression
func (*ProtoLiteral) ToProtoFuncArg ¶
func (t *ProtoLiteral) ToProtoFuncArg() *proto.FunctionArgument
func (*ProtoLiteral) ToProtoLiteral ¶
func (t *ProtoLiteral) ToProtoLiteral() *proto.Expression_Literal
func (*ProtoLiteral) ValueString ¶
func (t *ProtoLiteral) ValueString() string
func (*ProtoLiteral) Visit ¶
func (t *ProtoLiteral) Visit(VisitFunc) Expression
type ReferenceSegment ¶
type ReferenceSegment interface {
Reference
fmt.Stringer
GetChild() ReferenceSegment
GetType(types.Type) (types.Type, error)
ToProto() *proto.Expression_ReferenceSegment
Equals(ReferenceSegment) bool
}
func FlattenRefSegments ¶
func FlattenRefSegments(refs ...ReferenceSegment) ReferenceSegment
func RefSegmentFromProto ¶
func RefSegmentFromProto(p *proto.Expression_ReferenceSegment) ReferenceSegment
type RootRefType ¶
type RootRefType interface {
// contains filtered or unexported methods
}
RootRefType is a marker interface for types that can be used as a Root reference in a FieldReference.
A field reference is composed of two parts: a Root reference, which is the output of an expression in this relation or a previous one, and a ReferenceSegment or MaskedExpression, which allows referencing data within that data structure - e.g. a field in a struct, or a value in a list or map.
var RootReference RootRefType
type ScalarFunction ¶
type ScalarFunction struct {
// contains filtered or unexported fields
}
func NewCustomScalarFunc ¶
func NewCustomScalarFunc( reg ExtensionRegistry, v *extensions.ScalarFunctionVariant, outputType types.Type, opts []*types.FunctionOption, args ...types.FuncArg, ) (*ScalarFunction, error)
NewCustomScalarFunc doesn't validate that the ID can be found already in the registry with LookupScalarFunction and will construct the function as provided as long as the outputType is non-nil. In this case, the registry is only used to provide an anchor / function reference that can be used when serializing this expression to Protobuf. Guaranteeing that you have a valid expression returned.
Currently an error is only returned if outputType == nil
func NewScalarFunc ¶
func NewScalarFunc( reg ExtensionRegistry, id extensions.ID, opts []*types.FunctionOption, args ...types.FuncArg, ) (*ScalarFunction, error)
NewScalarFunc validates that the specified ID can be found in the registry via LookupScalarFunction and retrieves a function anchor to use.
If the name in the ID is not currently a compound signature and cannot be found in the registry, we'll attempt to construct the compound signature based on the types of the provided arguments and look it up that way. If both attempts fail to lookup the function, a substraitgo.ErrNotFound will be returned.
Currently the options are not validated against the function declaration but the number of arguments and their types will be validated in order to resolve the output type.
func (*ScalarFunction) CompoundName ¶
func (s *ScalarFunction) CompoundName() string
func (*ScalarFunction) Deterministic ¶
func (s *ScalarFunction) Deterministic() bool
func (*ScalarFunction) Equals ¶
func (s *ScalarFunction) Equals(rhs Expression) bool
func (*ScalarFunction) FuncRef ¶
func (s *ScalarFunction) FuncRef() uint32
func (*ScalarFunction) GetArgTypes ¶
func (s *ScalarFunction) GetArgTypes() []types.Type
func (*ScalarFunction) GetOption ¶
func (s *ScalarFunction) GetOption(name string) []string
func (*ScalarFunction) GetOptions ¶
func (s *ScalarFunction) GetOptions() []*types.FunctionOption
func (*ScalarFunction) GetType ¶
func (s *ScalarFunction) GetType() types.Type
func (*ScalarFunction) ID ¶
func (s *ScalarFunction) ID() extensions.ID
func (*ScalarFunction) IsScalar ¶
func (s *ScalarFunction) IsScalar() bool
func (*ScalarFunction) NArgs ¶
func (s *ScalarFunction) NArgs() int
func (*ScalarFunction) Name ¶
func (s *ScalarFunction) Name() string
func (*ScalarFunction) SessionDependant ¶
func (s *ScalarFunction) SessionDependant() bool
func (*ScalarFunction) String ¶
func (s *ScalarFunction) String() string
func (*ScalarFunction) ToProto ¶
func (s *ScalarFunction) ToProto() *proto.Expression
func (*ScalarFunction) ToProtoFuncArg ¶
func (s *ScalarFunction) ToProtoFuncArg() *proto.FunctionArgument
func (*ScalarFunction) Variadic ¶
func (s *ScalarFunction) Variadic() *extensions.VariadicBehavior
func (*ScalarFunction) Visit ¶
func (s *ScalarFunction) Visit(visit VisitFunc) Expression
type SingularOrList ¶
type SingularOrList struct {
Value Expression
Options []Expression
}
func (*SingularOrList) Equals ¶
func (ex *SingularOrList) Equals(other Expression) bool
func (*SingularOrList) GetType ¶
func (ex *SingularOrList) GetType() types.Type
func (*SingularOrList) IsScalar ¶
func (ex *SingularOrList) IsScalar() bool
func (*SingularOrList) String ¶
func (ex *SingularOrList) String() string
func (*SingularOrList) ToProto ¶
func (ex *SingularOrList) ToProto() *proto.Expression
func (*SingularOrList) ToProtoFuncArg ¶
func (ex *SingularOrList) ToProtoFuncArg() *proto.FunctionArgument
func (*SingularOrList) Visit ¶
func (ex *SingularOrList) Visit(visit VisitFunc) Expression
type SortField ¶
type SortField struct {
Expr Expression
Kind types.SortKind
}
func SortFieldFromProto ¶
func SortFieldFromProto( f *proto.SortField, baseSchema *types.RecordType, reg ExtensionRegistry, ) (sf SortField, err error)
type StructExpr ¶
type StructExpr struct {
Nullable bool
TypeVariationRef uint32
Fields []Expression
}
func (*StructExpr) Equals ¶
func (ex *StructExpr) Equals(other Expression) bool
func (*StructExpr) GetType ¶
func (ex *StructExpr) GetType() types.Type
func (*StructExpr) IsNullable ¶
func (ex *StructExpr) IsNullable() bool
func (*StructExpr) IsScalar ¶
func (ex *StructExpr) IsScalar() bool
func (*StructExpr) String ¶
func (ex *StructExpr) String() string
func (*StructExpr) ToProto ¶
func (ex *StructExpr) ToProto() *proto.Expression
func (*StructExpr) ToProtoFuncArg ¶
func (ex *StructExpr) ToProtoFuncArg() *proto.FunctionArgument
func (*StructExpr) TypeVariation ¶
func (ex *StructExpr) TypeVariation() uint32
func (*StructExpr) Visit ¶
func (ex *StructExpr) Visit(visit VisitFunc) Expression
type StructFieldRef ¶
type StructFieldRef struct {
Field int32
Child ReferenceSegment
}
func NewStructFieldRef ¶
func NewStructFieldRef(field int32) *StructFieldRef
func (*StructFieldRef) Equals ¶
func (r *StructFieldRef) Equals(rhs ReferenceSegment) bool
func (*StructFieldRef) GetChild ¶
func (r *StructFieldRef) GetChild() ReferenceSegment
func (*StructFieldRef) String ¶
func (r *StructFieldRef) String() string
func (*StructFieldRef) ToProto ¶
func (r *StructFieldRef) ToProto() *proto.Expression_ReferenceSegment
type StructLiteral ¶
type StructLiteral = NestedLiteral[StructLiteralValue]
Convenience names so that there is StructLiteral, ListLiteral and MapLiteral
type StructLiteralValue ¶
type StructLiteralValue []Literal
StructLiteralValue is a slice of other literals where each element in the slice is a different field in the struct
func StructLiteralFromProto
deprecated
func StructLiteralFromProto(s *proto.Expression_Literal_Struct) StructLiteralValue
Deprecated: use VirtualTableExprFromLiteralProto
func (StructLiteralValue) ToProto ¶
func (s StructLiteralValue) ToProto() *proto.Expression_Literal_Struct
type SwitchExpr ¶
type SwitchExpr struct {
// contains filtered or unexported fields
}
func NewSwitch ¶
func NewSwitch(match Expression, elseClause Expression, switchCases ...struct { If Literal Then Expression }) (*SwitchExpr, error)
NewSwitch constructs a switch statement. Will return an error in the following cases:
- match is nil
- len(switchCases) < 1
- the type of the If literal in each switchCase != match.GetType()
- the GetType for each "Then" of switch cases aren't the same
- elseClause.GetType() != switchCases.Then.GetType() if elseClause != nil
elseClause is allowed to be nil if there is no default case.
func (*SwitchExpr) Case ¶
func (ex *SwitchExpr) Case(i int) struct { If Literal Then Expression }
Case returns the pair of Literal and result Expression for the given index. It is not bounds checked.
func (*SwitchExpr) Else ¶
func (ex *SwitchExpr) Else() Expression
func (*SwitchExpr) Equals ¶
func (ex *SwitchExpr) Equals(other Expression) bool
func (*SwitchExpr) GetType ¶
func (ex *SwitchExpr) GetType() types.Type
func (*SwitchExpr) IsScalar ¶
func (ex *SwitchExpr) IsScalar() bool
func (*SwitchExpr) MatchExpr ¶
func (ex *SwitchExpr) MatchExpr() Expression
func (*SwitchExpr) NCases ¶
func (ex *SwitchExpr) NCases() int
NCases returns the number of case statements in this switch, not including the existences of a default else clause
func (*SwitchExpr) String ¶
func (ex *SwitchExpr) String() string
func (*SwitchExpr) ToProto ¶
func (ex *SwitchExpr) ToProto() *proto.Expression
func (*SwitchExpr) ToProtoFuncArg ¶
func (ex *SwitchExpr) ToProtoFuncArg() *proto.FunctionArgument
func (*SwitchExpr) Visit ¶
func (ex *SwitchExpr) Visit(visit VisitFunc) Expression
type Unbounded ¶
type Unbounded struct{}
func (Unbounded) ToProto ¶
func (Unbounded) ToProto() *proto.Expression_WindowFunction_Bound
type VirtualTableExpressionValue ¶
type VirtualTableExpressionValue []Expression
VirtualTableExpressionValue is a slice of other expression where each element in the slice is a different field in the struct
func (VirtualTableExpressionValue) ToProto ¶
func (s VirtualTableExpressionValue) ToProto() *proto.Expression_Nested_Struct
type VisitFunc ¶
type VisitFunc func(Expression) Expression
type WindowFunction ¶
type WindowFunction struct {
Sorts []SortField
Partitions []Expression
BoundsType types.BoundsType
LowerBound, UpperBound Bound
// contains filtered or unexported fields
}
func NewCustomWindowFunc ¶
func NewCustomWindowFunc( reg ExtensionRegistry, v *extensions.WindowFunctionVariant, outputType types.Type, opts []*types.FunctionOption, invoke types.AggregationInvocation, phase types.AggregationPhase, args ...types.FuncArg, ) (*WindowFunction, error)
func NewWindowFunc ¶
func NewWindowFunc( reg ExtensionRegistry, id extensions.ID, opts []*types.FunctionOption, invoke types.AggregationInvocation, phase types.AggregationPhase, args ...types.FuncArg, ) (*WindowFunction, error)
func (*WindowFunction) CompoundName ¶
func (w *WindowFunction) CompoundName() string
func (*WindowFunction) Decomposable ¶
func (w *WindowFunction) Decomposable() extensions.DecomposeType
func (*WindowFunction) Deterministic ¶
func (w *WindowFunction) Deterministic() bool
func (*WindowFunction) Equals ¶
func (w *WindowFunction) Equals(other Expression) bool
func (*WindowFunction) GetArgTypes ¶
func (w *WindowFunction) GetArgTypes() []types.Type
func (*WindowFunction) GetOptions ¶
func (w *WindowFunction) GetOptions() []*types.FunctionOption
func (*WindowFunction) GetType ¶
func (w *WindowFunction) GetType() types.Type
func (*WindowFunction) ID ¶
func (w *WindowFunction) ID() extensions.ID
func (*WindowFunction) IntermediateType ¶
func (w *WindowFunction) IntermediateType() (types.FuncDefArgType, error)
func (*WindowFunction) Invocation ¶
func (w *WindowFunction) Invocation() types.AggregationInvocation
func (*WindowFunction) IsScalar ¶
func (*WindowFunction) IsScalar() bool
func (*WindowFunction) MaxSet ¶
func (w *WindowFunction) MaxSet() int
func (*WindowFunction) NArgs ¶
func (w *WindowFunction) NArgs() int
func (*WindowFunction) Name ¶
func (w *WindowFunction) Name() string
func (*WindowFunction) Ordered ¶
func (w *WindowFunction) Ordered() bool
func (*WindowFunction) Phase ¶
func (w *WindowFunction) Phase() types.AggregationPhase
func (*WindowFunction) SessionDependant ¶
func (w *WindowFunction) SessionDependant() bool
func (*WindowFunction) String ¶
func (w *WindowFunction) String() string
func (*WindowFunction) ToProto ¶
func (w *WindowFunction) ToProto() *proto.Expression
func (*WindowFunction) ToProtoFuncArg ¶
func (w *WindowFunction) ToProtoFuncArg() *proto.FunctionArgument
func (*WindowFunction) Variadic ¶
func (w *WindowFunction) Variadic() *extensions.VariadicBehavior
func (*WindowFunction) Visit ¶
func (w *WindowFunction) Visit(visit VisitFunc) Expression
func (*WindowFunction) WindowType ¶
func (w *WindowFunction) WindowType() extensions.WindowType