Documentation
¶
Index ¶
- func AggregationTypeFromSub(subAggTypeName string) string
- func Build() error
- func GeometryToSQLValue(v any) ([]byte, error)
- func IntervalToSQLValue(v any) (string, error)
- func IsKnownJSONType(typeName string) bool
- func IsScalar(name string) bool
- func IsSubAggregationType(typeName string) bool
- func JSONTypeHint(typeName string) string
- func JSONTypeHintWithOk(typeName string) (string, bool)
- func ParseArray(typeName string, v any) (any, error)
- func ParseGeometryValue(v any) (orb.Geometry, error)
- func ParseIntervalValue(v any) (time.Duration, error)
- func ParseRangeValue(t RangeType, v any) (any, error)
- func ParseSQLInterval(s string) (time.Duration, error)
- func ParseScalarArray[T ScalarTypes](v any) ([]T, error)
- func ParseTimeValue(v any) (time.Time, error)
- func ParseValue(typeName string, v any) (any, error)
- func Register(scalar ScalarType)
- func SQLValueToGeometry(v any) (orb.Geometry, error)
- func Scalars() iter.Seq[ScalarType]
- func Sources() []*ast.Source
- func SubAggregationTypeName(aggTypeName string) string
- type Aggregatable
- type ArrayParser
- type BaseRange
- type Dimensional
- type ExtraFieldProvider
- type FieldArgumentsProvider
- type Filterable
- type Int32Range
- type Int64Range
- type Interval
- type JSONTypeHintProvider
- type ListFilterable
- type MeasurementAggregatable
- type RangeDetail
- type RangeType
- type SQLOutputTransformer
- type ScalarType
- type ScalarTypes
- type SubAggregatable
- type TimeRange
- type ValueParser
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregationTypeFromSub ¶
AggregationTypeFromSub returns the parent aggregation type name for a sub-aggregation type. E.g., "FloatSubAggregation" → "FloatAggregation". Returns "" if not found.
func Build ¶
func Build() error
Build validates that all registered scalars have non-empty names and SDL. Full SDL parsing validation happens at compile time when all sources are combined.
func GeometryToSQLValue ¶ added in v0.3.4
func IntervalToSQLValue ¶ added in v0.3.4
func IsKnownJSONType ¶
IsKnownJSONType returns true if the type name has a known JSON type mapping (scalar, aggregation, or sub-aggregation type).
func IsSubAggregationType ¶
IsSubAggregationType returns true if the type name is a scalar sub-aggregation type.
func JSONTypeHint ¶
JSONTypeHint returns the JSON extraction type hint for a type name. Checks scalars, their aggregation types, and their sub-aggregation types. Returns "" if not a known type or no hint available.
func JSONTypeHintWithOk ¶
JSONTypeHintWithOk returns the JSON extraction type hint and whether the type is known.
func ParseArray ¶
ParseArray dispatches array parsing to the scalar type's ArrayParser interface.
func ParseScalarArray ¶ added in v0.3.4
func ParseScalarArray[T ScalarTypes](v any) ([]T, error)
func ParseValue ¶
ParseValue dispatches value parsing to the scalar type's ValueParser interface.
func Register ¶
func Register(scalar ScalarType)
Register adds a scalar type to the global registry. If a scalar with the same name already exists, it is overwritten (last-write-wins).
func Scalars ¶
func Scalars() iter.Seq[ScalarType]
Scalars returns an iterator over all registered scalar types.
func SubAggregationTypeName ¶
SubAggregationTypeName returns the sub-aggregation type name for a given aggregation type. E.g., "FloatAggregation" → "FloatSubAggregation". Returns "" if not found.
Types ¶
type Aggregatable ¶
type Aggregatable interface {
AggregationTypeName() string
}
Aggregatable indicates the scalar supports aggregation.
type ArrayParser ¶
ArrayParser is implemented by scalar types that support array parsing.
type BaseRange ¶ added in v0.3.4
type BaseRange struct {
Type RangeType
Lower, Upper any
Detail RangeDetail
}
func (BaseRange) ToInt32Range ¶ added in v0.3.4
func (t BaseRange) ToInt32Range() (Int32Range, error)
func (BaseRange) ToInt64Range ¶ added in v0.3.4
func (t BaseRange) ToInt64Range() (Int64Range, error)
func (BaseRange) ToTimestampRange ¶ added in v0.3.4
type Dimensional ¶ added in v0.3.4
type Dimensional interface {
Len() int
}
type ExtraFieldProvider ¶
type ExtraFieldProvider interface {
ExtraFieldName() string
GenerateExtraField(fieldName string) *ast.FieldDefinition
}
ExtraFieldProvider indicates the scalar generates extra derived fields.
type FieldArgumentsProvider ¶
type FieldArgumentsProvider interface {
FieldArguments() ast.ArgumentDefinitionList
}
FieldArgumentsProvider indicates the scalar has field-level arguments (e.g., bucket for Timestamp, transforms for Geometry, struct for JSON).
type Filterable ¶
type Filterable interface {
FilterTypeName() string
}
Filterable indicates the scalar supports single-value filtering.
type Int32Range ¶ added in v0.3.4
type Int32Range struct {
Lower, Upper int32
Detail RangeDetail
}
type Int64Range ¶ added in v0.3.4
type Int64Range struct {
Lower, Upper int64
Detail RangeDetail
}
type Interval ¶ added in v0.3.4
func (Interval) MarshalJSON ¶ added in v0.3.4
func (*Interval) UnmarshalJSON ¶ added in v0.3.4
type JSONTypeHintProvider ¶
type JSONTypeHintProvider interface {
JSONTypeHint() string
}
JSONTypeHintProvider provides the JSON extraction type hint for engines. Hint examples: "string", "number", "bool", "timestamp".
type ListFilterable ¶
type ListFilterable interface {
ListFilterTypeName() string
}
ListFilterable indicates the scalar supports list-value filtering.
type MeasurementAggregatable ¶
type MeasurementAggregatable interface {
MeasurementAggregationTypeName() string
}
MeasurementAggregatable indicates the scalar supports measurement aggregation.
type RangeDetail ¶ added in v0.3.4
type RangeDetail int
const ( RangeEmpty RangeDetail = 1 << iota RangeUpperInfinity RangeLowerInfinity RangeUpperInclusive RangeLowerInclusive )
func ParseRangeDetail ¶ added in v0.3.4
func ParseRangeDetail(v any) (RangeDetail, error)
func (*RangeDetail) Clear ¶ added in v0.3.4
func (t *RangeDetail) Clear()
func (RangeDetail) IsEmpty ¶ added in v0.3.4
func (t RangeDetail) IsEmpty() bool
func (RangeDetail) IsLowerInclusive ¶ added in v0.3.4
func (t RangeDetail) IsLowerInclusive() bool
func (RangeDetail) IsLowerInfinity ¶ added in v0.3.4
func (t RangeDetail) IsLowerInfinity() bool
func (RangeDetail) IsUpperInclusive ¶ added in v0.3.4
func (t RangeDetail) IsUpperInclusive() bool
func (RangeDetail) IsUpperInfinity ¶ added in v0.3.4
func (t RangeDetail) IsUpperInfinity() bool
type SQLOutputTransformer ¶
type SQLOutputTransformer interface {
ToOutputSQL(sql string, raw bool) string
ToStructFieldSQL(sql string) string
}
SQLOutputTransformer is implemented by scalar types that need SQL output transformation (e.g., Geometry→ST_AsGeoJSON, H3Cell→h3_h3_to_string).
type ScalarType ¶
ScalarType represents a scalar's compilation-time metadata. Capabilities are determined via type assertions on optional interfaces (Filterable, ListFilterable, Aggregatable, MeasurementAggregatable, ExtraFieldProvider).
func Lookup ¶
func Lookup(name string) ScalarType
Lookup returns the scalar type with the given name, or nil if not found.
type ScalarTypes ¶ added in v0.3.4
type SubAggregatable ¶
type SubAggregatable interface {
SubAggregationTypeName() string
}
SubAggregatable indicates the scalar has a sub-aggregation type for nested aggregations.
type TimeRange ¶ added in v0.3.4
type TimeRange struct {
Lower, Upper time.Time
Detail RangeDetail
}
type ValueParser ¶
ValueParser is implemented by scalar types that need custom value parsing.
type Vector ¶ added in v0.3.4
type Vector []float64
func ParseVector ¶ added in v0.3.4
func (Vector) MarshalJSON ¶ added in v0.3.4
func (*Vector) UnmarshalJSON ¶ added in v0.3.4
Source Files
¶
- extra_field_geometry.go
- extra_field_timestamp.go
- extra_field_vector.go
- init.go
- interfaces.go
- registry.go
- scalar_arrays.go
- scalar_bigint.go
- scalar_bigintrange.go
- scalar_boolean.go
- scalar_date.go
- scalar_float.go
- scalar_geometry.go
- scalar_h3cell.go
- scalar_int.go
- scalar_interval.go
- scalar_intrange.go
- scalar_json.go
- scalar_range.go
- scalar_string.go
- scalar_time.go
- scalar_timestamp.go
- scalar_timestamprange.go
- scalar_vector.go