package extensions

import "github.com/substrait-io/substrait-go/v3/extensions"

Index

Constants

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

Functions

func EvaluateTypeExpression

func EvaluateTypeExpression(nullHandling NullabilityHandling, returnTypeExpr types.FuncDefArgType,
	funcParameters FuncParameterList, variadic *VariadicBehavior, argumentTypes []types.Type) (types.Type, error)

EvaluateTypeExpression evaluates the function return type given the input argumentTypes

funcParameters: the function parameters as defined in the function signature in the extension
argumentTypes: the actual argument types provided to the function

func HasSyncParams

func HasSyncParams(params []types.FuncDefArgType) bool

HasSyncParams This API returns if params share a leaf param name

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

func (s *AggregateFunctionVariant) ID() ID

func (*AggregateFunctionVariant) Intermediate

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

func (*AggregateFunctionVariant) Match

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

func (*AggregateFunctionVariant) MatchAt

func (s *AggregateFunctionVariant) MatchAt(typ types.Type, pos int) (bool, error)

func (*AggregateFunctionVariant) MaxArgumentCount

func (s *AggregateFunctionVariant) MaxArgumentCount() int

func (*AggregateFunctionVariant) MaxSet

func (s *AggregateFunctionVariant) MaxSet() int

func (*AggregateFunctionVariant) MinArgumentCount

func (s *AggregateFunctionVariant) MinArgumentCount() 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 Collection

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

func GetDefaultCollection

func GetDefaultCollection() (*Collection, error)

GetDefaultCollection returns a Collection that is loaded with the default Substrait extension definitions.

func GetDefaultCollectionWithNoError

func GetDefaultCollectionWithNoError() *Collection

GetDefaultCollectionWithNoError returns a Collection that is loaded with the default Substrait extension definitions. This version is provided for the ease of use of legacy code. Please use GetDefaultCollection instead.

func (*Collection) GetAggregateFunc

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

func (*Collection) GetAllAggregateFunctions

func (c *Collection) GetAllAggregateFunctions() []*AggregateFunctionVariant

func (*Collection) GetAllScalarFunctions

func (c *Collection) GetAllScalarFunctions() []*ScalarFunctionVariant

func (*Collection) GetAllWindowFunctions

func (c *Collection) GetAllWindowFunctions() []*WindowFunctionVariant

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
}

func (EnumArg) GetTypeExpression

func (v EnumArg) GetTypeExpression() types.FuncDefArgType

type FuncParameter

type FuncParameter interface {
	GetTypeExpression() types.FuncDefArgType
	// contains filtered or unexported methods
}

type FuncParameterList

type FuncParameterList []FuncParameter

func (*FuncParameterList) UnmarshalYAML

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

type Function

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

type FunctionVariant

type FunctionVariant interface {
	Name() string
	CompoundName() string
	Description() string
	Args() FuncParameterList
	Options() map[string]Option
	URI() string
	ResolveType(argTypes []types.Type) (types.Type, error)
	Variadic() *VariadicBehavior
	// Match this function matches input arguments against this functions parameter list
	// returns (true, nil) if all input argument can type replace the function definition argument
	// returns (false, err) for invalid input argument. For e.g. if input argument nullability is not correctly
	// set this function will return error
	// returns (false, nil) valid input arguments and argument list type replace parameter list
	Match(argumentTypes []types.Type) (bool, error)
	// MatchAt this function matches input argument at position against definition of this
	// functions argument at same position
	// returns (true, nil) if input argument can type replace the function definition argument
	// returns (false, err) for invalid input argument. For e.g. if input arg position is negative or
	// argument nullability is not correctly set this function will return error
	// returns (false, nil) valid input argument type and argument can't type replace parameter at argPos
	MatchAt(typ types.Type, pos int) (bool, error)
	// MinArgumentCount returns minimum number of arguments required for this function
	MinArgumentCount() int
	// MaxArgumentCount returns minimum number of arguments accepted by this function
	MaxArgumentCount() int
}

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
}

ID is 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             FuncParameterList      `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" default:"MIRROR"`
	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

func (s *ScalarFunctionVariant) ID() ID

func (*ScalarFunctionVariant) Match

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

func (*ScalarFunctionVariant) MatchAt

func (s *ScalarFunctionVariant) MatchAt(typ types.Type, pos int) (bool, error)

func (*ScalarFunctionVariant) MaxArgumentCount

func (s *ScalarFunctionVariant) MaxArgumentCount() int

func (*ScalarFunctionVariant) MinArgumentCount

func (s *ScalarFunctionVariant) MinArgumentCount() int

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        *parser.TypeExpression
}

func (TypeArg) GetTypeExpression

func (v TypeArg) GetTypeExpression() types.FuncDefArgType

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      string
	Description string
	Functions   TypeVariationFunctions
}

type TypeVariationFunctions

type TypeVariationFunctions string
const (
	TypeVariationInheritsFuncs TypeVariationFunctions = "INHERITS"
	TypeVariationSeparateFuncs TypeVariationFunctions = "SEPARATE"
	EnumTypeString                                    = "req" // TODO change this to "enum"
)

type ValueArg

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

func (ValueArg) GetTypeExpression

func (v ValueArg) GetTypeExpression() types.FuncDefArgType

type VariadicBehavior

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

func (*VariadicBehavior) IsValidArgumentCount

func (v *VariadicBehavior) IsValidArgumentCount(count int) bool

func (*VariadicBehavior) IsValidArgumentPosition

func (v *VariadicBehavior) IsValidArgumentPosition(index int) bool

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

func (s *WindowFunctionVariant) ID() ID

func (*WindowFunctionVariant) Intermediate

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

func (*WindowFunctionVariant) Match

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

func (*WindowFunctionVariant) MatchAt

func (s *WindowFunctionVariant) MatchAt(typ types.Type, pos int) (bool, error)

func (*WindowFunctionVariant) MaxArgumentCount

func (s *WindowFunctionVariant) MaxArgumentCount() int

func (*WindowFunctionVariant) MaxSet

func (s *WindowFunctionVariant) MaxSet() int

func (*WindowFunctionVariant) MinArgumentCount

func (s *WindowFunctionVariant) MinArgumentCount() 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
}

Source Files

extension_mgr.go simple_extension.go variants.go

Version
v3.9.1 (latest)
Published
Apr 7, 2025
Platform
linux/amd64
Imports
17 packages
Last checked
now

Tools for package owners.