Documentation
¶
Index ¶
- Variables
- type AttributeBinding
- type AttributeCatalog
- type AttributeFallbackKind
- type ColumnRef
- type FilterNode
- type Input
- type LogicOp
- type NormalizerOptions
- type Optimizer
- type Pagination
- type PatternKind
- type Plan
- type PlanExplain
- type Predicate
- type PredicateOp
- type SortDirection
- type SortKey
- type StorageTables
- type StorageTarget
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("query optimizer plan generation not implemented")
ErrNotImplemented is returned until the optimizer pipeline is fully implemented.
Functions ¶
This section is empty.
Types ¶
type AttributeBinding ¶
type AttributeBinding struct {
AttributeName string
AttributeID int16
ValueType ValueType
Storage StorageTarget
Column *ColumnRef
Fallback AttributeFallbackKind
InsideArray bool
}
AttributeBinding exposes metadata needed for normalization.
type AttributeCatalog ¶
type AttributeCatalog map[string]AttributeBinding
AttributeCatalog is a lookup map for attributes.
type AttributeFallbackKind ¶
type AttributeFallbackKind string
AttributeFallbackKind describes lossy storage behaviors that require rewrites.
const ( AttributeFallbackNone AttributeFallbackKind = "none" AttributeFallbackNumericToDouble AttributeFallbackKind = "numeric_to_double" AttributeFallbackDateToDouble AttributeFallbackKind = "date_to_double" AttributeFallbackDateToText AttributeFallbackKind = "date_to_text" AttributeFallbackBoolToDouble AttributeFallbackKind = "bool_to_double" AttributeFallbackBoolToText AttributeFallbackKind = "bool_to_text" )
type FilterNode ¶
type FilterNode struct {
Logic LogicOp
Predicate *Predicate
Children []*FilterNode
}
FilterNode preserves the original boolean structure of the request.
type Input ¶
type Input struct {
SchemaID int16
SchemaName string
Tables StorageTables
Filter *FilterNode
SortKeys []SortKey
Pagination Pagination
}
Input bundles all data required to build a SQL plan.
func NormalizeQuery ¶
func NormalizeQuery(req *forma.QueryRequest, schemaID int16, schemaName string, tables StorageTables, attrs AttributeCatalog, opts NormalizerOptions) (*Input, error)
NormalizeQuery converts a QueryRequest into the optimizer Input IR.
type NormalizerOptions ¶
NormalizerOptions controls pagination defaults when requests omit values.
type Pagination ¶
Pagination captures validated limit/offset.
type PatternKind ¶
type PatternKind string
PatternKind describes LIKE pattern semantics for text predicates.
const ( PatternKindNone PatternKind = "" PatternKindPrefix PatternKind = "prefix" PatternKindContains PatternKind = "contains" )
type Plan ¶
type Plan struct {
SQL string
Params []any
Explain PlanExplain
Metadata any // placeholder for future metadata payloads
}
Plan represents the executable statement plus diagnostics.
type PlanExplain ¶
type PlanExplain struct {
Driver string
MainFilters []string
EAVFilters []string
SortStrategy string
}
PlanExplain stores human-readable diagnostics for logging.
type Predicate ¶
type Predicate struct {
AttributeName string
AttributeID int16
ValueType ValueType
Operator PredicateOp
Value any
Storage StorageTarget
Column *ColumnRef
Pattern PatternKind
Fallback AttributeFallbackKind
InsideArray bool
}
Predicate describes a normalized filter expression.
type PredicateOp ¶
type PredicateOp string
PredicateOp enumerates normalized predicate operators.
const ( PredicateOpEquals PredicateOp = "=" PredicateOpNotEquals PredicateOp = "!=" PredicateOpGreaterThan PredicateOp = ">" PredicateOpGreaterEq PredicateOp = ">=" PredicateOpLessThan PredicateOp = "<" PredicateOpLessEq PredicateOp = "<=" PredicateOpLike PredicateOp = "LIKE" )
Supported predicate operators.
type SortDirection ¶
type SortDirection string
SortDirection enumerates normalized sort orderings.
const ( SortAsc SortDirection = "ASC" SortDesc SortDirection = "DESC" )
type SortKey ¶
type SortKey struct {
AttributeName string
AttributeID int16
ValueType ValueType
Direction SortDirection
Storage StorageTarget
Column *ColumnRef
Fallback AttributeFallbackKind
}
SortKey represents a normalized ordering requirement.
type StorageTables ¶
StorageTables captures the physical table names passed in from calling layers.
type StorageTarget ¶
type StorageTarget int
StorageTarget indicates whether the attribute lives in the main table or EAV.
const ( StorageTargetUnknown StorageTarget = iota StorageTargetMain StorageTargetEAV )