types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 6 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 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 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 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 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 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 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 SubAggregatable

type SubAggregatable interface {
	SubAggregationTypeName() string
}

SubAggregatable indicates the scalar has a sub-aggregation type for nested aggregations.

type ValueParser

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

ValueParser is implemented by scalar types that need custom value parsing.

Jump to

Keyboard shortcuts

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