types

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregationTypeFromSub

func AggregationTypeFromSub(subAggTypeName string) string

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 GeometryToSQLValue(v any) ([]byte, error)

func IntervalToSQLValue added in v0.3.4

func IntervalToSQLValue(v any) (string, error)

func IsKnownJSONType

func IsKnownJSONType(typeName string) bool

IsKnownJSONType returns true if the type name has a known JSON type mapping (scalar, aggregation, or sub-aggregation type).

func IsScalar

func IsScalar(name string) bool

IsScalar returns true if a scalar with the given name is registered.

func IsSubAggregationType

func IsSubAggregationType(typeName string) bool

IsSubAggregationType returns true if the type name is a scalar sub-aggregation type.

func JSONTypeHint

func JSONTypeHint(typeName string) string

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

func JSONTypeHintWithOk(typeName string) (string, bool)

JSONTypeHintWithOk returns the JSON extraction type hint and whether the type is known.

func ParseArray

func ParseArray(typeName string, v any) (any, error)

ParseArray dispatches array parsing to the scalar type's ArrayParser interface.

func ParseGeometryValue added in v0.3.4

func ParseGeometryValue(v any) (orb.Geometry, error)

func ParseIntervalValue added in v0.3.4

func ParseIntervalValue(v any) (time.Duration, error)

func ParseRangeValue added in v0.3.4

func ParseRangeValue(t RangeType, v any) (any, error)

func ParseSQLInterval added in v0.3.4

func ParseSQLInterval(s string) (time.Duration, error)

func ParseScalarArray added in v0.3.4

func ParseScalarArray[T ScalarTypes](v any) ([]T, error)

func ParseTimeValue added in v0.3.4

func ParseTimeValue(v any) (time.Time, error)

func ParseValue

func ParseValue(typeName string, v any) (any, error)

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 SQLValueToGeometry added in v0.3.4

func SQLValueToGeometry(v any) (orb.Geometry, error)

func Scalars

func Scalars() iter.Seq[ScalarType]

Scalars returns an iterator over all registered scalar types.

func Sources

func Sources() []*ast.Source

Sources returns all scalar SDL merged into ast.Source entries.

func SubAggregationTypeName

func SubAggregationTypeName(aggTypeName string) string

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

type ArrayParser interface {
	ParseArray(v any) (any, error)
}

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

func (t BaseRange) ToTimestampRange() (TimeRange, error)

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

type Interval time.Duration

func (Interval) MarshalJSON added in v0.3.4

func (i Interval) MarshalJSON() ([]byte, error)

func (*Interval) UnmarshalJSON added in v0.3.4

func (i *Interval) UnmarshalJSON(data []byte) error

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 RangeType added in v0.3.4

type RangeType int
const (
	RangeTypeInt32 RangeType = iota + 1
	RangeTypeInt64
	RangeTypeTimestamp
)

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

type ScalarType interface {
	Name() string
	SDL() string
}

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 ScalarTypes interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | ~string | ~bool | Int32Range | Int64Range | TimeRange | BaseRange | time.Time
}

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

type ValueParser interface {
	ParseValue(v any) (any, error)
}

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 ParseVector(data any) (Vector, error)

func (Vector) Len added in v0.3.4

func (v Vector) Len() int

func (Vector) MarshalJSON added in v0.3.4

func (v Vector) MarshalJSON() ([]byte, error)

func (*Vector) UnmarshalJSON added in v0.3.4

func (v *Vector) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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