extensions

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const SubstraitDefaultURIPrefix = "https://github.com/substrait-io/substrait/blob/main/extensions/"

Variables

This section is empty.

Functions

func EvaluateTypeExpression

func EvaluateTypeExpression(nullHandling NullabilityHandling, expr parser.TypeExpression, paramTypeList ArgumentList, actualTypes []types.Type) (types.Type, error)

Types

type AdvancedExtension

type AdvancedExtension = extensions.AdvancedExtension

type AggVariantOptions

type AggVariantOptions struct {
	Variadic         *VariadicBehavior
	SessionDependant bool
	Deterministic    bool
	Ordered          bool
	// value of 0 == unlimited
	MaxSet       uint
	Decomposable DecomposeType
	// should be a type expression
	// must not be empty if decomposable is not DecomposeNone
	IntermediateOutputType string
}

type AggregateFunction

type AggregateFunction struct {
	Name        string
	Description string
	Impls       []AggregateFunctionImpl
}

func (*AggregateFunction) GetVariants

func (s *AggregateFunction) GetVariants(uri string) []*AggregateFunctionVariant

func (*AggregateFunction) ResolveURI

func (s *AggregateFunction) ResolveURI(uri string) []FunctionVariant

type AggregateFunctionImpl

type AggregateFunctionImpl struct {
	ScalarFunctionImpl `yaml:",inline"`
	Intermediate       parser.TypeExpression
	Ordered            bool
	MaxSet             int
	Decomposable       DecomposeType
}

type AggregateFunctionVariant

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

func NewAggFuncVariant

func NewAggFuncVariant(id ID) *AggregateFunctionVariant

NewAggFuncVariant constructs a variant with the provided name and uri and uses the defaults for everything else.

Return expressions aren't included here as using this variant to construct an expression requires an output type argument. This is for creating an on-the-fly function variant that will not be registered as an extension.

func NewAggFuncVariantOpts

func NewAggFuncVariantOpts(id ID, opts AggVariantOptions) *AggregateFunctionVariant

func (*AggregateFunctionVariant) Args

func (*AggregateFunctionVariant) CompoundName

func (s *AggregateFunctionVariant) CompoundName() string

func (*AggregateFunctionVariant) Decomposability

func (s *AggregateFunctionVariant) Decomposability() DecomposeType

func (*AggregateFunctionVariant) Description

func (s *AggregateFunctionVariant) Description() string

func (*AggregateFunctionVariant) Deterministic

func (s *AggregateFunctionVariant) Deterministic() bool

func (*AggregateFunctionVariant) ID added in v0.4.2

func (s *AggregateFunctionVariant) ID() ID

func (*AggregateFunctionVariant) Intermediate

func (s *AggregateFunctionVariant) Intermediate() (types.Type, error)

func (*AggregateFunctionVariant) MaxSet

func (s *AggregateFunctionVariant) MaxSet() int

func (*AggregateFunctionVariant) Name

func (s *AggregateFunctionVariant) Name() string

func (*AggregateFunctionVariant) Nullability

func (*AggregateFunctionVariant) Options

func (s *AggregateFunctionVariant) Options() map[string]Option

func (*AggregateFunctionVariant) Ordered

func (s *AggregateFunctionVariant) Ordered() bool

func (*AggregateFunctionVariant) ResolveType

func (s *AggregateFunctionVariant) ResolveType(argumentTypes []types.Type) (types.Type, error)

func (*AggregateFunctionVariant) SessionDependent

func (s *AggregateFunctionVariant) SessionDependent() bool

func (*AggregateFunctionVariant) URI

func (*AggregateFunctionVariant) Variadic

type Argument

type Argument interface {
	// contains filtered or unexported methods
}

type ArgumentList

type ArgumentList []Argument

func (*ArgumentList) UnmarshalYAML

func (a *ArgumentList) UnmarshalYAML(fn func(interface{}) error) error

type Collection

type Collection struct {
	// contains filtered or unexported fields
}
var DefaultCollection Collection

DefaultCollection is loaded with the default Substrait extension definitions with the exception of decimal arithemtic. Decimal arithmetic functions are missing as the complex return type expressions are not yet implemented.

func (*Collection) GetAggregateFunc

func (c *Collection) GetAggregateFunc(id ID) (*AggregateFunctionVariant, bool)

func (*Collection) GetScalarFunc

func (c *Collection) GetScalarFunc(id ID) (*ScalarFunctionVariant, bool)

func (*Collection) GetType

func (c *Collection) GetType(id ID) (t Type, ok bool)

func (*Collection) GetTypeVariation

func (c *Collection) GetTypeVariation(id ID) (tv TypeVariation, ok bool)

func (*Collection) GetWindowFunc

func (c *Collection) GetWindowFunc(id ID) (*WindowFunctionVariant, bool)

func (*Collection) Load

func (c *Collection) Load(uri string, r io.Reader) error

func (*Collection) URILoaded

func (c *Collection) URILoaded(uri string) bool

type DecomposeType

type DecomposeType string
const (
	DecomposeNone DecomposeType = "NONE"
	DecomposeOne  DecomposeType = "ONE"
	DecomposeMany DecomposeType = "MANY"
)

type EnumArg

type EnumArg struct {
	Name        string `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
	Options     []string
}

type Function

type Function interface {
	ResolveURI(uri string) []FunctionVariant
}

type FunctionVariant

type FunctionVariant interface {
	Name() string
	CompoundName() string
	Description() string
	Args() ArgumentList
	Options() map[string]Option
	URI() string
	ResolveType(argTypes []types.Type) (types.Type, error)
	Variadic() *VariadicBehavior
}

type ID

type ID struct {
	URI string
	// Name of the object. For functions, a simple name may be used for lookups,
	// but as a unique identifier the compound name will be used
	Name string
}

The unique identifier for a substrait object

type NullabilityHandling

type NullabilityHandling string
const (
	MirrorNullability         NullabilityHandling = "MIRROR"
	DeclaredOutputNullability NullabilityHandling = "DECLARED_OUTPUT"
	DiscreteNullability       NullabilityHandling = "DISCRETE"
)

type Option

type Option struct {
	Description string `yaml:",omitempty"`
	Values      []string
}

type ParamType

type ParamType string
const (
	ParamDataType ParamType = "dataType"
	ParamBool     ParamType = "boolean"
	ParamInteger  ParamType = "integer"
	ParamEnum     ParamType = "enumeration"
	ParamString   ParamType = "string"
)

type ParameterConsistency

type ParameterConsistency string
const (
	ConsistentParams   ParameterConsistency = "CONSISTENT"
	InconsistentParams ParameterConsistency = "INCONSISTENT"
)

type ScalarFunction

type ScalarFunction struct {
	Name        string               `yaml:",omitempty"`
	Description string               `yaml:",omitempty,flow"`
	Impls       []ScalarFunctionImpl `yaml:",omitempty"`
}

func (*ScalarFunction) GetVariants

func (s *ScalarFunction) GetVariants(uri string) []*ScalarFunctionVariant

func (*ScalarFunction) ResolveURI

func (s *ScalarFunction) ResolveURI(uri string) []FunctionVariant

type ScalarFunctionImpl

type ScalarFunctionImpl struct {
	Args             ArgumentList          `yaml:",omitempty"`
	Options          map[string]Option     `yaml:",omitempty"`
	Variadic         *VariadicBehavior     `yaml:",omitempty"`
	SessionDependent bool                  `yaml:"sessionDependent,omitempty"`
	Deterministic    bool                  `yaml:",omitempty"`
	Nullability      NullabilityHandling   `yaml:",omitempty"`
	Return           parser.TypeExpression `yaml:",omitempty"`
	Implementation   map[string]string     `yaml:",omitempty"`
}

type ScalarFunctionVariant

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

func NewScalarFuncVariant

func NewScalarFuncVariant(id ID) *ScalarFunctionVariant

NewScalarFuncVariant constructs a variant with the provided name and uri and uses the defaults for everything else.

Return expressions aren't included here as using this variant to construct an expression requires an output type argument. This is for creating an on-the-fly function variant that will not be registered as an extension.

func NewScalarFuncVariantWithProps

func NewScalarFuncVariantWithProps(id ID, variadic *VariadicBehavior, sessionDependant, deterministic bool) *ScalarFunctionVariant

NewScalarFuncVariantWithProps is the same as NewScalarFuncVariant but allows setting the values for the SessionDependant, Variadic Behavior and Deterministic properties.

func (*ScalarFunctionVariant) Args

func (*ScalarFunctionVariant) CompoundName

func (s *ScalarFunctionVariant) CompoundName() string

func (*ScalarFunctionVariant) Description

func (s *ScalarFunctionVariant) Description() string

func (*ScalarFunctionVariant) Deterministic

func (s *ScalarFunctionVariant) Deterministic() bool

func (*ScalarFunctionVariant) ID added in v0.4.2

func (s *ScalarFunctionVariant) ID() ID

func (*ScalarFunctionVariant) Name

func (s *ScalarFunctionVariant) Name() string

func (*ScalarFunctionVariant) Nullability

func (s *ScalarFunctionVariant) Nullability() NullabilityHandling

func (*ScalarFunctionVariant) Options

func (s *ScalarFunctionVariant) Options() map[string]Option

func (*ScalarFunctionVariant) ResolveType

func (s *ScalarFunctionVariant) ResolveType(argumentTypes []types.Type) (types.Type, error)

func (*ScalarFunctionVariant) SessionDependent

func (s *ScalarFunctionVariant) SessionDependent() bool

func (*ScalarFunctionVariant) URI

func (s *ScalarFunctionVariant) URI() string

func (*ScalarFunctionVariant) Variadic

func (s *ScalarFunctionVariant) Variadic() *VariadicBehavior

type Set

type Set interface {
	DecodeTypeVariation(anchor uint32) (ID, bool)
	DecodeFunc(anchor uint32) (ID, bool)
	DecodeType(anchor uint32) (ID, bool)
	LookupTypeVariation(anchor uint32, c *Collection) (TypeVariation, bool)
	LookupType(anchor uint32, c *Collection) (Type, bool)
	LookupScalarFunction(anchor uint32, c *Collection) (*ScalarFunctionVariant, bool)
	LookupAggregateFunction(anchor uint32, c *Collection) (*AggregateFunctionVariant, bool)
	LookupWindowFunction(anchor uint32, c *Collection) (*WindowFunctionVariant, bool)

	FindURI(uri string) (uint32, bool)
	GetTypeAnchor(id ID) uint32
	GetFuncAnchor(id ID) uint32
	GetTypeVariationAnchor(id ID) uint32

	ToProto() ([]*extensions.SimpleExtensionURI, []*extensions.SimpleExtensionDeclaration)
}

func GetExtensionSet

func GetExtensionSet(plan TopLevel) Set

func NewSet

func NewSet() Set

type SimpleExtensionFile

type SimpleExtensionFile struct {
	Types              []Type              `yaml:"types,omitempty"`
	TypeVariations     []TypeVariation     `yaml:"type_variations,omitempty"`
	ScalarFunctions    []ScalarFunction    `yaml:"scalar_functions,omitempty"`
	AggregateFunctions []AggregateFunction `yaml:"aggregate_functions,omitempty"`
	WindowFunctions    []WindowFunction    `yaml:"window_functions,omitempty"`
}

type TopLevel

type TopLevel interface {
	GetExtensionUris() []*extensions.SimpleExtensionURI
	GetExtensions() []*extensions.SimpleExtensionDeclaration
}

type Type

type Type struct {
	Name       string
	Variadic   bool
	Structure  TypeDef `yaml:",omitempty"`
	Parameters []TypeParamDef
}

type TypeArg

type TypeArg struct {
	Name        string `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
	Type        string
}

type TypeDef

type TypeDef any

should be either a string or map[string]any

type TypeParamDef

type TypeParamDef struct {
	Name        string
	Description string
	Type        ParamType
	Min         int
	Max         int
	Options     []string
	Optional    bool
}

type TypeVariation

type TypeVariation struct {
	Name        string
	Parent      parser.TypeExpression
	Description string
	Functions   TypeVariationFunctions
}

type TypeVariationFunctions

type TypeVariationFunctions string
const (
	TypeVariationInheritsFuncs TypeVariationFunctions = "INHERITS"
	TypeVariationSeparateFuncs TypeVariationFunctions = "SEPARATE"
)

type ValueArg

type ValueArg struct {
	Name        string `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
	Value       *parser.TypeExpression
	Constant    bool `yaml:",omitempty"`
}

type VariadicBehavior

type VariadicBehavior struct {
	Min                  int                  `yaml:",omitempty"`
	Max                  int                  `yaml:",omitempty"`
	ParameterConsistency ParameterConsistency `yaml:"parameterConsistency,omitempty"`
}

type WindowFunction

type WindowFunction struct {
	Name        string
	Description string
	Impls       []WindowFunctionImpl
}

func (*WindowFunction) GetVariants

func (s *WindowFunction) GetVariants(uri string) []*WindowFunctionVariant

func (*WindowFunction) ResolveURI

func (s *WindowFunction) ResolveURI(uri string) []FunctionVariant

type WindowFunctionImpl

type WindowFunctionImpl struct {
	AggregateFunctionImpl `yaml:",inline"`
	WindowType            WindowType `yaml:"window_type"`
}

type WindowFunctionVariant

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

func NewWindowFuncVariant

func NewWindowFuncVariant(id ID) *WindowFunctionVariant

func NewWindowFuncVariantOpts

func NewWindowFuncVariantOpts(id ID, opts WindowVariantOpts) *WindowFunctionVariant

func (*WindowFunctionVariant) Args

func (*WindowFunctionVariant) CompoundName

func (s *WindowFunctionVariant) CompoundName() string

func (*WindowFunctionVariant) Decomposability

func (s *WindowFunctionVariant) Decomposability() DecomposeType

func (*WindowFunctionVariant) Description

func (s *WindowFunctionVariant) Description() string

func (*WindowFunctionVariant) Deterministic

func (s *WindowFunctionVariant) Deterministic() bool

func (*WindowFunctionVariant) ID added in v0.4.2

func (s *WindowFunctionVariant) ID() ID

func (*WindowFunctionVariant) Intermediate

func (s *WindowFunctionVariant) Intermediate() (types.Type, error)

func (*WindowFunctionVariant) MaxSet

func (s *WindowFunctionVariant) MaxSet() int

func (*WindowFunctionVariant) Name

func (s *WindowFunctionVariant) Name() string

func (*WindowFunctionVariant) Nullability

func (s *WindowFunctionVariant) Nullability() NullabilityHandling

func (*WindowFunctionVariant) Options

func (s *WindowFunctionVariant) Options() map[string]Option

func (*WindowFunctionVariant) Ordered

func (s *WindowFunctionVariant) Ordered() bool

func (*WindowFunctionVariant) ResolveType

func (s *WindowFunctionVariant) ResolveType(argumentTypes []types.Type) (types.Type, error)

func (*WindowFunctionVariant) SessionDependent

func (s *WindowFunctionVariant) SessionDependent() bool

func (*WindowFunctionVariant) URI

func (s *WindowFunctionVariant) URI() string

func (*WindowFunctionVariant) Variadic

func (s *WindowFunctionVariant) Variadic() *VariadicBehavior

func (*WindowFunctionVariant) WindowType

func (s *WindowFunctionVariant) WindowType() WindowType

type WindowType

type WindowType string
const (
	StreamingWindow WindowType = "STREAMING"
	PartitionWindow WindowType = "PARTITION"
)

type WindowVariantOpts

type WindowVariantOpts struct {
	Variadic         *VariadicBehavior
	SessionDependant bool
	Deterministic    bool
	Ordered          bool
	// value of 0 == unlimited
	MaxSet       uint
	Decomposable DecomposeType
	// should be a type expression
	// must not be empty if decomposable is not DecomposeNone
	IntermediateOutputType string
	WindowType             WindowType
}

Jump to

Keyboard shortcuts

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