operators

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayOperator

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

ArrayOperator handles array operations like map, filter, reduce, all, some, none, merge.

func NewArrayOperator

func NewArrayOperator(config *OperatorConfig) *ArrayOperator

NewArrayOperator creates a new ArrayOperator instance with optional config.

func (*ArrayOperator) ToSQL

func (a *ArrayOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts an array operation to SQL.

type ComparisonOperator

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

ComparisonOperator handles comparison operators (==, ===, !=, !==, >, >=, <, <=).

func NewComparisonOperator

func NewComparisonOperator(config *OperatorConfig) *ComparisonOperator

NewComparisonOperator creates a new comparison operator with optional config.

func (*ComparisonOperator) ToSQL

func (c *ComparisonOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts a comparison operator to SQL.

type DataOperator

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

DataOperator handles data access operators (var, missing, missing_some).

func NewDataOperator

func NewDataOperator(config *OperatorConfig) *DataOperator

NewDataOperator creates a new data operator with optional config.

func (*DataOperator) ToSQL

func (d *DataOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts a data operator to SQL.

type LogicalOperator

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

LogicalOperator handles logical operators (and, or, !, !!, if).

func NewLogicalOperator

func NewLogicalOperator(config *OperatorConfig) *LogicalOperator

NewLogicalOperator creates a new logical operator with optional config.

func (*LogicalOperator) ToSQL

func (l *LogicalOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts a logical operator to SQL.

type NumericOperator

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

NumericOperator handles numeric operations like +, -, *, /, %, max, min.

func NewNumericOperator

func NewNumericOperator(config *OperatorConfig) *NumericOperator

NewNumericOperator creates a new NumericOperator instance with optional config.

func (*NumericOperator) ToSQL

func (n *NumericOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts a numeric operation to SQL.

type OperatorConfig added in v1.0.1

type OperatorConfig struct {
	Schema  SchemaProvider
	Dialect dialect.Dialect
}

OperatorConfig holds shared configuration for all operators. By using a shared config object, all operators automatically see configuration changes without requiring individual SetSchema calls.

func NewOperatorConfig added in v1.0.1

func NewOperatorConfig(d dialect.Dialect, schema SchemaProvider) *OperatorConfig

NewOperatorConfig creates a new operator config with dialect and optional schema.

func (*OperatorConfig) GetDialect added in v1.0.2

func (c *OperatorConfig) GetDialect() dialect.Dialect

GetDialect returns the configured dialect.

func (*OperatorConfig) HasSchema added in v1.0.1

func (c *OperatorConfig) HasSchema() bool

HasSchema returns true if a schema is configured.

func (*OperatorConfig) IsBigQuery added in v1.0.2

func (c *OperatorConfig) IsBigQuery() bool

IsBigQuery returns true if the dialect is BigQuery.

func (*OperatorConfig) IsSpanner added in v1.0.2

func (c *OperatorConfig) IsSpanner() bool

IsSpanner returns true if the dialect is Spanner.

func (*OperatorConfig) ValidateDialect added in v1.0.2

func (c *OperatorConfig) ValidateDialect(operator string) error

ValidateDialect checks if the configured dialect is supported. Returns an error for unsupported or unspecified dialects. This should be called by operators to ensure dialect compatibility.

type ProcessedValue added in v1.0.2

type ProcessedValue struct {
	// Value is the string representation (either SQL expression or literal value)
	Value string
	// IsSQL indicates whether Value is a pre-processed SQL expression (true)
	// or a literal value that may need quoting (false)
	IsSQL bool
}

ProcessedValue represents a value that has been processed during transpilation. It carries metadata about whether the value is already SQL or a literal that needs quoting.

func LiteralResult added in v1.0.2

func LiteralResult(val string) ProcessedValue

LiteralResult creates a ProcessedValue marked as a literal. Use this when returning literal values that may need quoting.

func SQLResult added in v1.0.2

func SQLResult(sql string) ProcessedValue

SQLResult creates a ProcessedValue marked as SQL. Use this when returning generated SQL expressions from operators.

func (ProcessedValue) IsEmpty added in v1.0.2

func (p ProcessedValue) IsEmpty() bool

IsEmpty returns true if the value is empty.

func (ProcessedValue) String added in v1.0.2

func (p ProcessedValue) String() string

String returns the value as a string.

type SchemaProvider added in v1.0.1

type SchemaProvider interface {
	// HasField checks if a field exists in the schema
	HasField(fieldName string) bool
	// GetFieldType returns the type of a field as a string, or empty string if not found
	GetFieldType(fieldName string) string
	// ValidateField checks if a field exists and returns an error if not
	ValidateField(fieldName string) error
	// IsArrayType checks if a field is of array type
	IsArrayType(fieldName string) bool
	// IsStringType checks if a field is of string type
	IsStringType(fieldName string) bool
	// IsNumericType checks if a field is of numeric type (integer or number)
	IsNumericType(fieldName string) bool
	// IsBooleanType checks if a field is of boolean type
	IsBooleanType(fieldName string) bool
	// IsEnumType checks if a field is of enum type
	IsEnumType(fieldName string) bool
	// GetAllowedValues returns the allowed values for an enum field
	GetAllowedValues(fieldName string) []string
	// ValidateEnumValue checks if a value is valid for an enum field
	ValidateEnumValue(fieldName, value string) error
}

SchemaProvider provides schema information for field validation and type checking.

type StringOperator

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

StringOperator handles string operations like cat, substr.

func NewStringOperator

func NewStringOperator(config *OperatorConfig) *StringOperator

NewStringOperator creates a new StringOperator instance with optional config.

func (*StringOperator) ToSQL

func (s *StringOperator) ToSQL(operator string, args []interface{}) (string, error)

ToSQL converts a string operation to SQL.

Jump to

Keyboard shortcuts

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