Help us shape the future of Go! Take the 2026 Go Developer Survey

engines

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: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughParamsToApply   = fmt.Errorf("not enough params to apply to query")
	ErrNotLastNParamsWasApplied = fmt.Errorf("not all last N params was applied")
)

Functions

func ApplyQueryParams

func ApplyQueryParams(e Engine, query string, params []any) (string, int, error)

func Ident

func Ident(s string) string

func JsonToStruct

func JsonToStruct(field *ast.Field, prefix string, useNativeTypes bool, byFieldFieldSource bool) string

func SQLValueArrayFormatter

func SQLValueArrayFormatter[T ctypes.ScalarTypes](e Engine, values []T) (string, error)

Types

type DuckDB

type DuckDB struct {
}

func NewDuckDB

func NewDuckDB() *DuckDB

func (DuckDB) AddObjectFields

func (e DuckDB) AddObjectFields(sqlName string, fields map[string]string) string

func (DuckDB) AggregateFuncAny

func (e DuckDB) AggregateFuncAny(sql string) string

func (DuckDB) AggregateFuncSQL

func (e DuckDB) AggregateFuncSQL(funcName, sql, path, factor string, field *ast.FieldDefinition, _ bool, args map[string]any, params []any) (string, []any, error)

func (DuckDB) ApplyFieldTransforms

func (e DuckDB) ApplyFieldTransforms(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

func (*DuckDB) Capabilities added in v0.2.1

func (e *DuckDB) Capabilities() *compiler.EngineCapabilities

func (DuckDB) ExtractJSONStruct

func (e DuckDB) ExtractJSONStruct(sql string, jsonStruct map[string]any) string

func (DuckDB) ExtractJSONTypedValue

func (e DuckDB) ExtractJSONTypedValue(sql, path, t string) string

func (DuckDB) ExtractNestedTypedValue

func (e DuckDB) ExtractNestedTypedValue(sql, path, t string) string

func (*DuckDB) FieldValueByPath

func (e *DuckDB) FieldValueByPath(sqlName, path string) string

func (*DuckDB) FilterOperationSQLValue

func (e *DuckDB) FilterOperationSQLValue(sqlName, path, op string, value any, params []any) (string, []any, error)

func (*DuckDB) FunctionCall added in v0.1.5

func (e *DuckDB) FunctionCall(name string, positional []any, named map[string]any) (string, error)

func (DuckDB) GeometryTransform

func (e DuckDB) GeometryTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (DuckDB) JSONTypeCast

func (e DuckDB) JSONTypeCast(sql string) string

func (*DuckDB) LateralJoin

func (e *DuckDB) LateralJoin(sql, alias string) string

func (DuckDB) MakeObject

func (e DuckDB) MakeObject(fields map[string]string) string

func (DuckDB) PackFieldsToObject

func (e DuckDB) PackFieldsToObject(prefix string, field *ast.Field) string

func (*DuckDB) RepackObject

func (e *DuckDB) RepackObject(sql string, field *ast.Field) string

func (*DuckDB) SQLValue

func (e *DuckDB) SQLValue(v any) (string, error)

func (DuckDB) TimestampTransform

func (e DuckDB) TimestampTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (*DuckDB) Type

func (e *DuckDB) Type() Type

func (*DuckDB) UnpackObjectToFieldList

func (e *DuckDB) UnpackObjectToFieldList(sql string, field *ast.Field) string

create fields list for the first level of object (struct)

func (*DuckDB) VectorDistanceSQL added in v0.1.28

func (e *DuckDB) VectorDistanceSQL(sql, distMetric string, vector ctypes.Vector, params []any) (string, []any, error)

func (*DuckDB) VectorTransform added in v0.1.28

func (e *DuckDB) VectorTransform(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

type DuckLake added in v0.3.2

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

DuckLake engine delegates all SQL generation to DuckDB but reports SupportTimeTravel: true in its capabilities.

func NewDuckLake added in v0.3.2

func NewDuckLake() *DuckLake

func (*DuckLake) AddObjectFields added in v0.3.2

func (e *DuckLake) AddObjectFields(sqlName string, fields map[string]string) string

func (*DuckLake) AggregateFuncAny added in v0.3.2

func (e *DuckLake) AggregateFuncAny(sql string) string

func (*DuckLake) AggregateFuncSQL added in v0.3.2

func (e *DuckLake) AggregateFuncSQL(funcName, sql, path, factor string, originField *ast.FieldDefinition, isHyperTable bool, args map[string]any, params []any) (string, []any, error)

EngineAggregator interface

func (*DuckLake) ApplyFieldTransforms added in v0.3.2

func (e *DuckLake) ApplyFieldTransforms(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

func (*DuckLake) Capabilities added in v0.3.2

func (e *DuckLake) Capabilities() *compiler.EngineCapabilities

func (*DuckLake) ExtractJSONStruct added in v0.3.2

func (e *DuckLake) ExtractJSONStruct(sql string, jsonStruct map[string]any) string

func (*DuckLake) ExtractNestedTypedValue added in v0.3.2

func (e *DuckLake) ExtractNestedTypedValue(sql, path, t string) string

func (*DuckLake) FieldValueByPath added in v0.3.2

func (e *DuckLake) FieldValueByPath(sqlName, path string) string

func (*DuckLake) FilterOperationSQLValue added in v0.3.2

func (e *DuckLake) FilterOperationSQLValue(sqlName, path, op string, value any, params []any) (string, []any, error)

func (*DuckLake) FunctionCall added in v0.3.2

func (e *DuckLake) FunctionCall(name string, positional []any, named map[string]any) (string, error)

func (*DuckLake) JSONTypeCast added in v0.3.2

func (e *DuckLake) JSONTypeCast(sql string) string

func (*DuckLake) LateralJoin added in v0.3.2

func (e *DuckLake) LateralJoin(sql, alias string) string

func (*DuckLake) MakeObject added in v0.3.2

func (e *DuckLake) MakeObject(fields map[string]string) string

func (*DuckLake) PackFieldsToObject added in v0.3.2

func (e *DuckLake) PackFieldsToObject(prefix string, field *ast.Field) string

func (*DuckLake) RepackObject added in v0.3.2

func (e *DuckLake) RepackObject(sqlName string, field *ast.Field) string

func (*DuckLake) SQLValue added in v0.3.2

func (e *DuckLake) SQLValue(v any) (string, error)

func (*DuckLake) TimestampTransform added in v0.3.2

func (e *DuckLake) TimestampTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (*DuckLake) Type added in v0.3.2

func (e *DuckLake) Type() Type

func (*DuckLake) UnpackObjectToFieldList added in v0.3.2

func (e *DuckLake) UnpackObjectToFieldList(sqlName string, field *ast.Field) string

func (*DuckLake) VectorDistanceSQL added in v0.3.2

func (e *DuckLake) VectorDistanceSQL(sql, distMetric string, vector ctypes.Vector, params []any) (string, []any, error)

EngineVectorDistanceCalculator interface

type Engine

type Engine interface {
	Type() Type
	Capabilities() *compiler.EngineCapabilities
	SQLValue(any) (string, error)
	FunctionCall(name string, positional []any, named map[string]any) (string, error)
	RepackObject(sqlName string, field *ast.Field) string
	UnpackObjectToFieldList(sqlName string, field *ast.Field) string
	FilterOperationSQLValue(sqlName, path, op string, value any, params []any) (string, []any, error)
	FieldValueByPath(sqlName, path string) string
	PackFieldsToObject(prefix string, field *ast.Field) string
	MakeObject(fields map[string]string) string
	AddObjectFields(sqlName string, fields map[string]string) string
	ApplyFieldTransforms(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)
	ExtractJSONStruct(sql string, jsonStruct map[string]any) string
	TimestampTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string
	// ExtractNestedTypedValue extracts value from nested field by path and cast it to type
	// type can be one of: number, string, bool, "" (empty string) - for extract json as is
	ExtractNestedTypedValue(sql, path, t string) string
	LateralJoin(sql, alias string) string
}

type EngineAggregator

type EngineAggregator interface {
	// AggregateFuncSQL returns SQL for aggregate function
	Engine
	AggregateFuncSQL(funcName, sql, path, factor string, originField *ast.FieldDefinition, isHyperTable bool, args map[string]any, params []any) (string, []any, error)
	AggregateFuncAny(sql string) string
	JSONTypeCast(sql string) string
}

type EngineKeyWordExtender

type EngineKeyWordExtender interface {
	KeyWords() []string
}

type EngineQueryScanner

type EngineQueryScanner interface {
	Engine
	WarpScann(db, query string) string
	WrapExec(db, query string) string
}

type EngineTypeCaster

type EngineTypeCaster interface {
	Engine
	ToIntermediateType(*ast.Field) (string, error)
	CastFromIntermediateType(field *ast.Field, toJSON bool) (string, error)
}

type EngineVectorDistanceCalculator added in v0.1.28

type EngineVectorDistanceCalculator interface {
	VectorDistanceSQL(sql, distMetric string, vector ctypes.Vector, params []any) (string, []any, error)
}

type HttpEngine

type HttpEngine struct {
	*DuckDB
}

func NewHttp

func NewHttp() *HttpEngine

func (*HttpEngine) Capabilities added in v0.2.1

func (e *HttpEngine) Capabilities() *compiler.EngineCapabilities

func (*HttpEngine) Type

func (e *HttpEngine) Type() Type

type Iceberg added in v0.3.3

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

Iceberg engine delegates all SQL generation to DuckDB but reports SupportTimeTravel: true in its capabilities.

func NewIceberg added in v0.3.3

func NewIceberg() *Iceberg

func (*Iceberg) AddObjectFields added in v0.3.3

func (e *Iceberg) AddObjectFields(sqlName string, fields map[string]string) string

func (*Iceberg) AggregateFuncAny added in v0.3.3

func (e *Iceberg) AggregateFuncAny(sql string) string

func (*Iceberg) AggregateFuncSQL added in v0.3.3

func (e *Iceberg) AggregateFuncSQL(funcName, sql, path, factor string, originField *ast.FieldDefinition, isHyperTable bool, args map[string]any, params []any) (string, []any, error)

EngineAggregator interface

func (*Iceberg) ApplyFieldTransforms added in v0.3.3

func (e *Iceberg) ApplyFieldTransforms(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

func (*Iceberg) Capabilities added in v0.3.3

func (e *Iceberg) Capabilities() *compiler.EngineCapabilities

func (*Iceberg) ExtractJSONStruct added in v0.3.3

func (e *Iceberg) ExtractJSONStruct(sql string, jsonStruct map[string]any) string

func (*Iceberg) ExtractNestedTypedValue added in v0.3.3

func (e *Iceberg) ExtractNestedTypedValue(sql, path, t string) string

func (*Iceberg) FieldValueByPath added in v0.3.3

func (e *Iceberg) FieldValueByPath(sqlName, path string) string

func (*Iceberg) FilterOperationSQLValue added in v0.3.3

func (e *Iceberg) FilterOperationSQLValue(sqlName, path, op string, value any, params []any) (string, []any, error)

func (*Iceberg) FunctionCall added in v0.3.3

func (e *Iceberg) FunctionCall(name string, positional []any, named map[string]any) (string, error)

func (*Iceberg) JSONTypeCast added in v0.3.3

func (e *Iceberg) JSONTypeCast(sql string) string

func (*Iceberg) LateralJoin added in v0.3.3

func (e *Iceberg) LateralJoin(sql, alias string) string

func (*Iceberg) MakeObject added in v0.3.3

func (e *Iceberg) MakeObject(fields map[string]string) string

func (*Iceberg) PackFieldsToObject added in v0.3.3

func (e *Iceberg) PackFieldsToObject(prefix string, field *ast.Field) string

func (*Iceberg) RepackObject added in v0.3.3

func (e *Iceberg) RepackObject(sqlName string, field *ast.Field) string

func (*Iceberg) SQLValue added in v0.3.3

func (e *Iceberg) SQLValue(v any) (string, error)

func (*Iceberg) TimestampTransform added in v0.3.3

func (e *Iceberg) TimestampTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (*Iceberg) Type added in v0.3.3

func (e *Iceberg) Type() Type

func (*Iceberg) UnpackObjectToFieldList added in v0.3.3

func (e *Iceberg) UnpackObjectToFieldList(sqlName string, field *ast.Field) string

func (*Iceberg) VectorDistanceSQL added in v0.3.3

func (e *Iceberg) VectorDistanceSQL(sql, distMetric string, vector ctypes.Vector, params []any) (string, []any, error)

EngineVectorDistanceCalculator interface

type MssqlEngine added in v0.2.1

type MssqlEngine struct {
	*DuckDB
}

func NewMssql added in v0.2.1

func NewMssql() *MssqlEngine

func (*MssqlEngine) Capabilities added in v0.2.1

func (e *MssqlEngine) Capabilities() *compiler.EngineCapabilities

func (*MssqlEngine) Type added in v0.2.1

func (e *MssqlEngine) Type() Type

type MySqlEngine added in v0.2.1

type MySqlEngine struct {
	*DuckDB
}

func NewMySql added in v0.2.1

func NewMySql() *MySqlEngine

func (*MySqlEngine) Capabilities added in v0.2.1

func (e *MySqlEngine) Capabilities() *compiler.EngineCapabilities

func (*MySqlEngine) Type added in v0.2.1

func (e *MySqlEngine) Type() Type

type Postgres

type Postgres struct {
}

func NewPostgres

func NewPostgres() *Postgres

func (*Postgres) AddObjectFields

func (e *Postgres) AddObjectFields(sqlName string, fields map[string]string) string

func (Postgres) AggregateFuncAny

func (e Postgres) AggregateFuncAny(sql string) string

func (Postgres) AggregateFuncSQL

func (e Postgres) AggregateFuncSQL(funcName, sql, path, factor string, field *ast.FieldDefinition, isHyperTable bool, args map[string]any, params []any) (string, []any, error)

func (Postgres) ApplyFieldTransforms

func (e Postgres) ApplyFieldTransforms(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

func (*Postgres) Capabilities added in v0.2.1

func (e *Postgres) Capabilities() *compiler.EngineCapabilities

func (*Postgres) CastFromIntermediateType

func (e *Postgres) CastFromIntermediateType(f *ast.Field, toJSON bool) (string, error)

func (Postgres) ExtractJSONStruct

func (e Postgres) ExtractJSONStruct(sql string, jsonStruct map[string]any) string

func (Postgres) ExtractNestedTypedValue

func (e Postgres) ExtractNestedTypedValue(sql, path, t string) string

func (*Postgres) FieldValueByPath

func (e *Postgres) FieldValueByPath(sqlName, path string) string

func (*Postgres) FilterOperationSQLValue

func (e *Postgres) FilterOperationSQLValue(sqlName, path, op string, value any, params []any) (string, []any, error)

TODO add compiler options to enable/disable type of operations and types support

func (*Postgres) FunctionCall added in v0.1.5

func (e *Postgres) FunctionCall(name string, positional []any, named map[string]any) (string, error)

func (Postgres) GeometryTransform

func (e Postgres) GeometryTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (Postgres) JSONTypeCast

func (e Postgres) JSONTypeCast(sql string) string

func (Postgres) LateralJoin

func (e Postgres) LateralJoin(sql, alias string) string

func (Postgres) MakeObject

func (e Postgres) MakeObject(fields map[string]string) string

func (Postgres) PackFieldsToObject

func (e Postgres) PackFieldsToObject(prefix string, field *ast.Field) string

func (*Postgres) RepackObject

func (e *Postgres) RepackObject(sql string, field *ast.Field) string

func (*Postgres) SQLValue

func (e *Postgres) SQLValue(v any) (string, error)

func (Postgres) TimestampTransform

func (e Postgres) TimestampTransform(sql string, field *ast.Field, args sdl.FieldQueryArguments) string

func (*Postgres) ToIntermediateType

func (e *Postgres) ToIntermediateType(f *ast.Field) (string, error)

func (*Postgres) Type

func (e *Postgres) Type() Type

func (*Postgres) UnpackObjectToFieldList

func (e *Postgres) UnpackObjectToFieldList(sql string, field *ast.Field) string

func (*Postgres) VectorDistanceSQL added in v0.1.28

func (e *Postgres) VectorDistanceSQL(sql, distMetric string, vector ctypes.Vector, params []any) (string, []any, error)

func (*Postgres) VectorTransform added in v0.1.28

func (e *Postgres) VectorTransform(ctx context.Context, qe types.Querier, sql string, field *ast.Field, args sdl.FieldQueryArguments, params []any) (string, []any, error)

func (*Postgres) WarpScann

func (e *Postgres) WarpScann(db, query string) string

func (*Postgres) WrapExec

func (e *Postgres) WrapExec(db, query string) string

type SelectedField

type SelectedField struct {
	Field  *ast.Field
	OnType string // works for in inline fragments to select only some fields
}

type SelectionSet

type SelectionSet []SelectedField

func SelectedFields

func SelectedFields(ss ast.SelectionSet) SelectionSet

func (SelectionSet) AsSelectionSet added in v0.1.18

func (ss SelectionSet) AsSelectionSet() ast.SelectionSet

func (SelectionSet) ForAlias

func (ss SelectionSet) ForAlias(alias string) *SelectedField

func (SelectionSet) ForName

func (ss SelectionSet) ForName(name string) *SelectedField

func (SelectionSet) ForPath

func (ss SelectionSet) ForPath(path string) *SelectedField

func (SelectionSet) ScalarForPath added in v0.1.15

func (ss SelectionSet) ScalarForPath(path string) *SelectedField

type Type

type Type string
const (
	TypePostgres Type = "postgres"
	TypeDuckDB   Type = "duckdb"
	TypeHttp     Type = "http"
	TypeMssql    Type = "mssql"
	TypeMySql    Type = "mysql"
	TypeDuckLake Type = "ducklake"
	TypeIceberg  Type = "iceberg"
)

Jump to

Keyboard shortcuts

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