expressions

package
v0.0.0-...-60a9d3e Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyContext = noopContext{}

Functions

func Fields

func Fields(expr Expression) []shared.Field

func IsArithmetic

func IsArithmetic(expr Expression) (_ ArithmeticType, left, right Expression)

func IsComparison

func IsComparison(expr Expression) (_ ComparisonType, left, right Expression)

func SubsumesOrder

func SubsumesOrder(a, b OrderExpression) bool

Types

type AggregateExpression

type AggregateExpression interface {
	Step(ctx ExpressionContext, row shared.Row) error
	Done(ctx ExpressionContext) (any, error)
}

type ArithmeticType

type ArithmeticType int
const (
	ArithmeticTypeUnknown ArithmeticType = iota
	ArithmeticTypeAddition
	ArithmeticTypeSubtraction
	ArithmeticTypeMultiplication
	ArithmeticTypeDivision
)

func ArithmeticTypeFromString

func ArithmeticTypeFromString(operator string) ArithmeticType

func (ArithmeticType) IsSymmetric

func (at ArithmeticType) IsSymmetric() bool

func (ArithmeticType) String

func (at ArithmeticType) String() string

type ComparisonType

type ComparisonType int
const (
	ComparisonTypeUnknown ComparisonType = iota
	ComparisonTypeEquals
	ComparisonTypeDistinctFrom
	ComparisonTypeLessThanEquals
	ComparisonTypeLessThan
	ComparisonTypeGreaterThanEquals
	ComparisonTypeGreaterThan
)

func ComparisonTypeFromString

func ComparisonTypeFromString(operator string) ComparisonType

func (ComparisonType) Flip

func (ct ComparisonType) Flip() ComparisonType

func (ComparisonType) MatchesOrderType

func (ct ComparisonType) MatchesOrderType(lVal, rVal any) (bool, error)

func (ComparisonType) String

func (ct ComparisonType) String() string

type CompositeExpression

type CompositeExpression interface {
	Children() []Expression
}

type Expression

type Expression interface {
	fmt.Stringer

	Equal(other Expression) bool
	Fold() Expression
	Map(f func(Expression) Expression) Expression
	ValueFrom(context ExpressionContext, row shared.Row) (any, error)
}

func Conjunctions

func Conjunctions(e Expression) []Expression

func Disjunctions

func Disjunctions(e Expression) []Expression

func FilterDifference

func FilterDifference(filter, childFilter Expression) Expression

func FilterIntersection

func FilterIntersection(filter, childFilter Expression) Expression

func NewAddition

func NewAddition(left, right Expression) Expression

func NewAnd

func NewAnd(left, right Expression) Expression

func NewBetween

func NewBetween(left, middle, right Expression) Expression

func NewBetweenSymmetric

func NewBetweenSymmetric(left, middle, right Expression) Expression

func NewConcat

func NewConcat(left, right Expression) Expression

func NewConstant

func NewConstant(value any) Expression

func NewDivision

func NewDivision(left, right Expression) Expression

func NewEquals

func NewEquals(left, right Expression) Expression

func NewFunction

func NewFunction(name string, args []Expression) Expression

func NewGreaterThan

func NewGreaterThan(left, right Expression) Expression

func NewGreaterThanEquals

func NewGreaterThanEquals(left, right Expression) Expression

func NewILike

func NewILike(left, right Expression) Expression

func NewIsDistinctFrom

func NewIsDistinctFrom(left, right Expression) Expression

func NewIsFalse

func NewIsFalse(expression Expression) Expression

func NewIsNull

func NewIsNull(expression Expression) Expression

func NewIsTrue

func NewIsTrue(expression Expression) Expression

func NewIsUnknown

func NewIsUnknown(expression Expression) Expression

func NewLessThan

func NewLessThan(left, right Expression) Expression

func NewLessThanEquals

func NewLessThanEquals(left, right Expression) Expression

func NewLike

func NewLike(left, right Expression) Expression

func NewMultiplication

func NewMultiplication(left, right Expression) Expression

func NewNamed

func NewNamed(field shared.Field) Expression

func NewNot

func NewNot(expression Expression) Expression

func NewOr

func NewOr(left, right Expression) Expression

func NewSubtraction

func NewSubtraction(left, right Expression) Expression

func NewUnaryMinus

func NewUnaryMinus(expression Expression) Expression

func NewUnaryPlus

func NewUnaryPlus(expression Expression) Expression

func UnionFilters

func UnionFilters(filters ...Expression) Expression

type ExpressionContext

type ExpressionContext interface {
	GetSequence(name string) (*sequence.Sequence, bool)
	GetFunction(name string) (functions.Function, bool)
	GetAggregate(name string) (aggregates.Aggregate, bool)
}

type ExpressionWithDirection

type ExpressionWithDirection struct {
	Expression Expression
	Reverse    bool
}

func (ExpressionWithDirection) Fold

type NamedExpression

type NamedExpression interface {
	Field() shared.Field
}

type OrderExpression

type OrderExpression interface {
	Expressions() []ExpressionWithDirection
	Fold() OrderExpression
	Map(f func(e Expression) Expression) OrderExpression
}

func NewOrderExpression

func NewOrderExpression(expressions []ExpressionWithDirection) OrderExpression

Jump to

Keyboard shortcuts

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