physical

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MPL-2.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExplainExpr added in v0.4.0

func ExplainExpr(expr Expression, withTypeInfo bool) *graph.Node

func ExplainNode added in v0.4.0

func ExplainNode(node Node, withTypeInfo bool) *graph.Node

func VariableNameMatchesField added in v0.4.0

func VariableNameMatchesField(varName, fieldName string) bool

func WithNoRetractions added in v0.6.0

func WithNoRetractions(noRetractions bool) func(schema *Schema)

Types

type Aggregate

type Aggregate struct {
	Name                string
	OutputType          octosql.Type
	AggregateDescriptor AggregateDescriptor
}

type AggregateDescriptor added in v0.4.0

type AggregateDescriptor struct {
	ArgumentType octosql.Type
	OutputType   octosql.Type
	TypeFn       func(octosql.Type) (octosql.Type, bool)
	Prototype    func() nodes.Aggregate
}

type AggregateDetails added in v0.4.0

type AggregateDetails struct {
	Description string
	Descriptors []AggregateDescriptor
}

type And

type And struct {
	Arguments []Expression
}

type Coalesce added in v0.4.0

type Coalesce struct {
	Arguments []Expression
}

type Constant

type Constant struct {
	Value octosql.Value
}

type CountingTrigger added in v0.3.0

type CountingTrigger struct {
	TriggerAfter uint
}

type Database added in v0.4.0

type Database interface {
	ListTables(ctx context.Context) ([]string, error)
	GetTable(ctx context.Context, name string, options map[string]string) (DatasourceImplementation, Schema, error)
}

type Datasource added in v0.4.0

type Datasource struct {
	Name, Alias              string
	DatasourceImplementation DatasourceImplementation
	VariableMapping          map[string]string
	Predicates               []Expression
}

func (*Datasource) PushDownPredicates added in v0.4.0

func (node *Datasource) PushDownPredicates(newPredicates, pushedDownPredicates []Expression) (rejected []Expression, pushedDown []Expression, changed bool)

type DatasourceImplementation added in v0.4.0

type DatasourceImplementation interface {
	Materialize(ctx context.Context, env Environment, schema Schema, pushedDownPredicates []Expression) (execution.Node, error)
	PushDownPredicates(newPredicates, pushedDownPredicates []Expression) (rejected, pushedDown []Expression, changed bool)
}

type DatasourceRepository added in v0.4.0

type DatasourceRepository struct {
	// TODO: A może jednak ten bardziej dynamiczny interfejs? Że database.<table> i wtedy sie resolvuje
	// Bo inaczej będzie na start strasznie dużo rzeczy ładować niepotrzebnych dla wszystkich
	// skonfigurowanych baz danych.
	Databases    map[string]func() (Database, error)
	FileHandlers map[string]func(ctx context.Context, name string, options map[string]string) (DatasourceImplementation, Schema, error)
}

func (*DatasourceRepository) GetDatasource added in v0.4.0

func (dr *DatasourceRepository) GetDatasource(ctx context.Context, name string, options map[string]string) (DatasourceImplementation, Schema, error)

type Distinct

type Distinct struct {
	Source Node
}

type EndOfStreamTrigger added in v0.4.0

type EndOfStreamTrigger struct {
}

type Environment added in v0.4.0

type Environment struct {
	Aggregates      map[string]AggregateDetails
	Datasources     *DatasourceRepository
	Functions       map[string]FunctionDetails
	PhysicalConfig  map[string]interface{}
	VariableContext *VariableContext
}

TODO: There should be a seperate MaterializationContext.

func (Environment) WithRecordSchema added in v0.4.0

func (env Environment) WithRecordSchema(schema Schema) Environment

type Expression

type Expression struct {
	Type octosql.Type

	ExpressionType ExpressionType
	// Only one of the below may be non-null.
	Variable          *Variable
	Constant          *Constant
	FunctionCall      *FunctionCall
	And               *And
	Or                *Or
	QueryExpression   *QueryExpression
	Coalesce          *Coalesce
	Tuple             *Tuple
	TypeAssertion     *TypeAssertion
	TypeCast          *TypeCast
	ObjectFieldAccess *ObjectFieldAccess
}

func RenameVariablesExpr added in v0.4.0

func RenameVariablesExpr(oldToNew map[string]string, expr Expression) Expression

func (*Expression) Materialize

func (expr *Expression) Materialize(ctx context.Context, env Environment) (execution.Expression, error)

func (Expression) SplitByAnd added in v0.4.0

func (expr Expression) SplitByAnd() []Expression

func (Expression) VariablesUsed added in v0.4.0

func (expr Expression) VariablesUsed() []string

type ExpressionType added in v0.4.0

type ExpressionType int
const (
	ExpressionTypeVariable ExpressionType = iota
	ExpressionTypeConstant
	ExpressionTypeFunctionCall
	ExpressionTypeAnd
	ExpressionTypeOr
	ExpressionTypeQueryExpression
	ExpressionTypeCoalesce
	ExpressionTypeTuple
	ExpressionTypeTypeAssertion
	ExpressionTypeTypeCast
	ExpressionTypeObjectFieldAccess
)

func (ExpressionType) String added in v0.4.0

func (t ExpressionType) String() string

type Filter

type Filter struct {
	Source    Node
	Predicate Expression
}

type FunctionCall added in v0.4.0

type FunctionCall struct {
	Name               string
	Arguments          []Expression
	FunctionDescriptor FunctionDescriptor
}

type FunctionDescriptor added in v0.4.0

type FunctionDescriptor struct {
	ArgumentTypes []octosql.Type
	OutputType    octosql.Type
	TypeFn        func([]octosql.Type) (octosql.Type, bool) `json:"-"`
	Strict        bool
	Function      func([]octosql.Value) (octosql.Value, error) `json:"-"`
}

type FunctionDetails added in v0.4.0

type FunctionDetails struct {
	Description string
	Descriptors []FunctionDescriptor
}

type GroupBy

type GroupBy struct {
	Source               Node
	Aggregates           []Aggregate
	AggregateExpressions []Expression
	Key                  []Expression
	// Either index to Key, or -1, if none.
	KeyEventTimeIndex int
	Trigger           Trigger
}

type InMemoryRecords added in v0.7.4

type InMemoryRecords struct {
	Records []execution.Record
}

type LookupJoin added in v0.3.0

type LookupJoin struct {
	Source, Joined Node
}

type Map

type Map struct {
	Source      Node
	Expressions []Expression
}

type MultiTrigger added in v0.4.0

type MultiTrigger struct {
	Triggers []Trigger
}

type Node

type Node struct {
	Schema Schema

	NodeType NodeType
	// Only one of the below may be non-null.
	Datasource              *Datasource
	Distinct                *Distinct
	Filter                  *Filter
	GroupBy                 *GroupBy
	LookupJoin              *LookupJoin
	StreamJoin              *StreamJoin
	Map                     *Map
	TableValuedFunction     *TableValuedFunction
	Unnest                  *Unnest
	InMemoryRecords         *InMemoryRecords
	OuterJoin               *OuterJoin
	OrderSensitiveTransform *OrderSensitiveTransform
}

func RenameVariables added in v0.4.0

func RenameVariables(oldToNew map[string]string, node Node) Node

func (*Node) Materialize

func (node *Node) Materialize(ctx context.Context, env Environment) (execution.Node, error)

type NodeType added in v0.4.0

type NodeType int
const (
	NodeTypeDatasource NodeType = iota
	NodeTypeDistinct
	NodeTypeFilter
	NodeTypeGroupBy
	NodeTypeLookupJoin
	NodeTypeStreamJoin
	NodeTypeMap

	NodeTypeTableValuedFunction
	NodeTypeUnnest

	NodeTypeInMemoryRecords
	NodeTypeOuterJoin
	NodeTypeOrderSensitiveTransform
)

func (NodeType) String added in v0.4.0

func (t NodeType) String() string

type ObjectFieldAccess added in v0.5.0

type ObjectFieldAccess struct {
	Object Expression
	Field  string
}

type Or

type Or struct {
	Arguments []Expression
}

type OrderSensitiveTransform added in v0.8.0

type OrderSensitiveTransform struct {
	Source                      Node
	OrderByKey                  []Expression
	OrderByDirectionMultipliers []int
	Limit                       *Expression
}

type OuterJoin added in v0.8.0

type OuterJoin struct {
	Left, Right       Node
	LeftKey, RightKey []Expression
	IsLeft, IsRight   bool // Full Outer Join will have both true.
}

type QueryExpression added in v0.4.0

type QueryExpression struct {
	Source Node
}

type Schema added in v0.4.0

type Schema struct {
	Fields []SchemaField
	// TimeField is -1 if not present.
	TimeField     int
	NoRetractions bool
}

func NewSchema added in v0.4.0

func NewSchema(fields []SchemaField, timeField int, options ...SchemaOption) Schema

type SchemaField added in v0.4.0

type SchemaField struct {
	Name string
	Type octosql.Type
}

type SchemaOption added in v0.6.0

type SchemaOption func(schema *Schema)

type StreamJoin added in v0.3.0

type StreamJoin struct {
	Left, Right       Node
	LeftKey, RightKey []Expression
}

type TableValuedFunction added in v0.2.0

type TableValuedFunction struct {
	Name               string
	Arguments          map[string]TableValuedFunctionArgument
	FunctionDescriptor TableValuedFunctionDescriptor
}

type TableValuedFunctionArgument added in v0.4.0

type TableValuedFunctionArgument struct {
	TableValuedFunctionArgumentType TableValuedFunctionArgumentType
	// Only one of the below may be non-null.
	Expression *TableValuedFunctionArgumentExpression
	Table      *TableValuedFunctionArgumentTable
	Descriptor *TableValuedFunctionArgumentDescriptor
}

func (*TableValuedFunctionArgument) String added in v0.4.0

func (arg *TableValuedFunctionArgument) String() string

type TableValuedFunctionArgumentDescriptor added in v0.4.0

type TableValuedFunctionArgumentDescriptor struct {
	Descriptor string
}

type TableValuedFunctionArgumentExpression added in v0.4.0

type TableValuedFunctionArgumentExpression struct {
	Expression Expression
}

type TableValuedFunctionArgumentTable added in v0.4.0

type TableValuedFunctionArgumentTable struct {
	Table Node
}

type TableValuedFunctionArgumentType added in v0.4.0

type TableValuedFunctionArgumentType int
const (
	TableValuedFunctionArgumentTypeExpression TableValuedFunctionArgumentType = iota
	TableValuedFunctionArgumentTypeTable
	TableValuedFunctionArgumentTypeDescriptor
)

type TableValuedFunctionDescriptor added in v0.4.0

type TableValuedFunctionDescriptor struct {
	Materialize func(context.Context, Environment, map[string]TableValuedFunctionArgument) (execution.Node, error)
}

type Transformers

type Transformers struct {
	NodeTransformer       func(node Node) Node
	ExpressionTransformer func(expr Expression) Expression
}

func (*Transformers) TransformExpr added in v0.4.0

func (t *Transformers) TransformExpr(expr Expression) Expression

func (*Transformers) TransformNode added in v0.4.0

func (t *Transformers) TransformNode(node Node) Node

type Trigger added in v0.3.0

type Trigger struct {
	TriggerType TriggerType
	// Only one of the below may be non-null.
	CountingTrigger    *CountingTrigger
	EndOfStreamTrigger *EndOfStreamTrigger
	WatermarkTrigger   *WatermarkTrigger
	MultiTrigger       *MultiTrigger
}

func (*Trigger) Materialize added in v0.3.0

func (t *Trigger) Materialize(ctx context.Context, env Environment) func() execution.Trigger

func (*Trigger) NoRetractions added in v0.6.0

func (t *Trigger) NoRetractions() bool

NoRetractions indicates whether the trigger can result in retractions of keys, or not. In other words, if a single key can be triggered multiple times.

type TriggerType added in v0.4.0

type TriggerType int
const (
	TriggerTypeCounting TriggerType = iota
	TriggerTypeEndOfStream
	TriggerTypeWatermark
	TriggerTypeMulti
)

func (TriggerType) String added in v0.4.0

func (t TriggerType) String() string

type Tuple

type Tuple struct {
	Arguments []Expression
}

type TypeAssertion added in v0.4.0

type TypeAssertion struct {
	Expression Expression
	TargetType octosql.Type
}

type TypeCast added in v0.9.2

type TypeCast struct {
	Expression   Expression
	TargetTypeID octosql.TypeID
}

type Unnest added in v0.4.0

type Unnest struct {
	Source Node
	Field  string
}

type Variable

type Variable struct {
	Name     string
	IsLevel0 bool
}

type VariableContext added in v0.4.0

type VariableContext struct {
	Parent *VariableContext
	Fields []SchemaField
}

func (*VariableContext) WithRecordSchema added in v0.4.0

func (varCtx *VariableContext) WithRecordSchema(schema Schema) *VariableContext

type WatermarkTrigger added in v0.3.0

type WatermarkTrigger struct {
	TimeFieldIndex int
}

Jump to

Keyboard shortcuts

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