bydbql

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bydbql provides BanyanDB Query Language (BydbQL) parsing and translation capabilities.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMeasureQuery = errors.New("invalid measure query")

ErrInvalidMeasureQuery identifies invalid typed measure syntax or bound values.

Functions

func BindParams added in v0.11.0

func BindParams(g *Grammar, params []*modelv1.TagValue) error

BindParams binds positional parameters to the `?` placeholders in the parsed grammar, in their order of appearance in the query text. After a successful call, the grammar is indistinguishable from one parsed with literal values, so the transformer needs no placeholder awareness. Callers must invoke it before Transform even when params is empty, so a query holding unbound placeholders is rejected instead of silently misinterpreted. Parameter positions in error messages are 1-based.

Binding mutates the grammar in place, so a grammar binds exactly once: rebinding is rejected and a failed bind leaves the grammar partially bound and unusable — parse the query again in both cases. For parse-once/bind-many reuse, use Prepare and (*PreparedStatement).Bind, which never mutate the parsed template.

Types

type BoundQuery added in v0.11.0

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

BoundQuery pairs an immutable prepared statement with the values bound for one request. Its values are the per-request overlay indexed by placeholder position, allocated by Bind and never shared or mutated after. Pass it to Transformer.TransformBound.

type Grammar

type Grammar struct {
	Select *GrammarSelectStatement `parser:"  @@"`
	TopN   *GrammarTopNStatement   `parser:"| @@"`
	// contains filtered or unexported fields
}

Grammar represents the root of a BydbQL statement parsed by Participle.

func ParseQuery

func ParseQuery(query string) (*Grammar, error)

ParseQuery parses a BydbQL query string into a Grammar struct.

type GrammarAggregateFunction

type GrammarAggregateFunction struct {
	Argument *GrammarExpression
	Function string                 `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"`
	Distinct bool                   `parser:"'(' @'DISTINCT'?"`
	Column   *GrammarIdentifierPath `parser:"@@"`
	TypeSpec *string                `parser:"( '::' @('TAG'|'FIELD') )? ')'"`
}

GrammarAggregateFunction represents aggregate functions. DISTINCT is grammatically accepted after any function — participle struct tags can't express a per-alternative semantic predicate — ParseQuery's post-parse check (checkAggregateAndGroupByShape) rejects it outside COUNT.

type GrammarAndExpr

type GrammarAndExpr struct {
	Left  *GrammarPredicate  `parser:"@@"`
	Right []*GrammarAndRight `parser:"@@*"`
}

GrammarAndExpr represents AND expression.

type GrammarAndRight

type GrammarAndRight struct {
	And   string            `parser:"@'AND'"`
	Right *GrammarPredicate `parser:"@@"`
}

GrammarAndRight represents right side of AND.

type GrammarBinaryPredicate

type GrammarBinaryPredicate struct {
	Identifier *GrammarIdentifierPath      `parser:"@@"`
	Tail       *GrammarBinaryPredicateTail `parser:"@@"`
}

GrammarBinaryPredicate captures comparison or MATCH predicates sharing an identifier left-hand side.

type GrammarBinaryPredicateTail

type GrammarBinaryPredicateTail struct {
	Match   *GrammarMatchTail   `parser:"  @@"`
	Compare *GrammarCompareTail `parser:"| @@"`
}

GrammarBinaryPredicateTail distinguishes between a MATCH suffix and a standard comparison operator.

type GrammarColumn

type GrammarColumn struct {
	Pos          lexer.Position
	SingleQuoted bool
	All          bool
	Expression   *GrammarExpression
	Aggregate    *GrammarAggregateFunction `parser:"( @@"`
	Identifier   *GrammarIdentifierPath    `parser:"| @@ )"`
	TypeSpec     *string                   `parser:"( '::' @('TAG'|'FIELD') )?"`
	Alias        *GrammarIdentifierPath    `parser:"( 'AS' @@ )?"`
}

GrammarColumn represents a column in projection.

type GrammarCompareTail

type GrammarCompareTail struct {
	Operator   string                     `parser:"@( '=' | '!=' | '>=' | '<=' | '>' | '<' )"`
	Value      *GrammarValue              `parser:"@@"`
	Adjustment *GrammarIntervalAdjustment `parser:"@@?"`
}

GrammarCompareTail represents traditional binary comparison operators.

type GrammarExpression added in v0.12.0

type GrammarExpression struct {
	Op             string
	Args           []*GrammarExpression
	Identifier     *GrammarIdentifierPath
	TypeSpec       *string
	Temporal       *GrammarCompareTail
	Aggregate      *GrammarAggregateFunction
	Literal        ql.ExpressionScalar
	Type           ql.ExpressionType
	Param          bool
	ListParam      bool
	MembershipList bool
	ParamIndex     int
}

GrammarExpression is a typed scalar expression before schema and parameter resolution.

type GrammarFromClause

type GrammarFromClause struct {
	From         string                `parser:"@'FROM'"`
	ResourceType string                `parser:"( @('STREAM'|'MEASURE'|'TRACE'|'PROPERTY')"`
	ResourceName string                `parser:"@Ident"`
	In           *GrammarInClause      `parser:"@@"`
	Shorthand    *GrammarMeasureSource `parser:"| @@ )"`
	Stage        *GrammarStageClause   `parser:"@@?"`
}

GrammarFromClause represents FROM clause.

type GrammarGroupByClause

type GrammarGroupByClause struct {
	Group   string                  `parser:"@'GROUP'"`
	By      string                  `parser:"@'BY'"`
	Columns []*GrammarGroupByColumn `parser:"@@ ( ',' @@ )*"`
}

GrammarGroupByClause represents GROUP BY clause.

type GrammarGroupByColumn

type GrammarGroupByColumn struct {
	Expression *GrammarExpression
	Ordinal    *int                   `parser:"( @Int"`
	TimeBucket *GrammarTimeBucket     `parser:"| @@"`
	Identifier *GrammarIdentifierPath `parser:" | @@ )"`
	TypeSpec   *string                `parser:"( '::' @('TAG'|'FIELD') )?"`
}

GrammarGroupByColumn represents a column in GROUP BY: a plain tag/field identifier, or the TIME_BUCKET(...) pseudo-column.

type GrammarHavingClause added in v0.12.0

type GrammarHavingClause struct {
	Expression *GrammarExpression
}

GrammarHavingClause filters completed measure groups.

type GrammarHavingPredicate

type GrammarHavingPredicate struct {
	Identifier *GrammarIdentifierPath `parser:"@@"`
	Not        *string                `parser:"@'NOT'?"`
	Having     string                 `parser:"@('HAVING'|'CONTAINS')"`
	Values     *GrammarHavingValues   `parser:"@@"`
}

GrammarHavingPredicate represents infix HAVING/CONTAINS membership and their negations.

type GrammarHavingValues

type GrammarHavingValues struct {
	Single *GrammarValue   `parser:"  @@"`
	Array  []*GrammarValue `parser:"| '(' @@ ( ',' @@ )* ')'"`
}

GrammarHavingValues represents values in HAVING.

type GrammarIdentifierPart

type GrammarIdentifierPart struct {
	Ident   *string `parser:"  @Ident"`
	Keyword *string `parser:"| @Keyword"`
}

GrammarIdentifierPart Can be either an Ident or a Keyword (keywords are allowed in paths, but not as standalone identifiers).

func (*GrammarIdentifierPart) Value

func (p *GrammarIdentifierPart) Value() string

Value returns the string value of the identifier part.

type GrammarIdentifierPath

type GrammarIdentifierPath struct {
	QuotedIdent *string                  `parser:"  ( @QuotedIdent | @String )"`
	First       *GrammarIdentifierPart   `parser:"| @@"`
	Rest        []*GrammarIdentifierPart `parser:"  ( '.' @@ )*"`
}

GrammarIdentifierPath Examples: column_name, _column, response.time, metadata.service.id, "count", 'trace.span.id'.

func (*GrammarIdentifierPath) ToString

func (g *GrammarIdentifierPath) ToString(hasTypeSpec bool) (string, error)

ToString converts identifier path to string representation.

type GrammarInClause

type GrammarInClause struct {
	In     string   `parser:"@'IN'"`
	LParen bool     `parser:"@'('?"`
	Groups []string `parser:"@Ident ( ',' @Ident )*"`
	RParen bool     `parser:"@')'?"`
}

GrammarInClause represents IN clause.

type GrammarInPredicate

type GrammarInPredicate struct {
	Identifier *GrammarIdentifierPath `parser:"@@"`
	Not        *string                `parser:"@'NOT'?"`
	In         string                 `parser:"@'IN'"`
	Values     []*GrammarValue        `parser:"'(' @@? ( ',' @@ )* ')'"`
}

GrammarInPredicate represents IN/NOT IN predicate.

type GrammarIntervalAdjustment added in v0.12.0

type GrammarIntervalAdjustment struct {
	Sign     string `parser:"@('+'|'-') 'INTERVAL'"`
	Duration string `parser:"@String"`
}

GrammarIntervalAdjustment is fixed-duration arithmetic on a timestamp.

type GrammarLimitClause

type GrammarLimitClause struct {
	Limit      string `parser:"@'LIMIT'"`
	Value      int    `parser:"( @Int"`
	Param      bool   `parser:"| @Param )"`
	ParamIndex int
}

GrammarLimitClause represents LIMIT clause.

type GrammarMatchTail

type GrammarMatchTail struct {
	MatchToken string              `parser:"@'MATCH'"`
	LParen     string              `parser:"@'('"`
	Values     *GrammarMatchValues `parser:"@@"`
	Analyzer   *string             `parser:"( ',' @String"`
	Operator   *string             `parser:"  ( ',' @String )? )?"`
	RParen     string              `parser:"@')'"`
}

GrammarMatchTail represents the RHS of a MATCH predicate.

type GrammarMatchValues

type GrammarMatchValues struct {
	Single *GrammarValue   `parser:"  @@"`
	Array  []*GrammarValue `parser:"| '(' @@ ( ',' @@ )* ')'"`
}

GrammarMatchValues represents values in MATCH.

type GrammarMeasureSource added in v0.12.0

type GrammarMeasureSource struct {
	Group string `parser:"@Ident '.'"`
	Name  string `parser:"@Ident"`
}

GrammarMeasureSource is the measure-only group.resource source shorthand.

type GrammarNowValue added in v0.12.0

type GrammarNowValue struct {
	Now string `parser:"@'NOW' '(' ')'"`
}

GrammarNowValue represents the execution clock, captured once per query.

type GrammarOffsetClause

type GrammarOffsetClause struct {
	Offset     string `parser:"@'OFFSET'"`
	Value      int    `parser:"( @Int"`
	Param      bool   `parser:"| @Param )"`
	ParamIndex int
}

GrammarOffsetClause represents OFFSET clause.

type GrammarOrExpr

type GrammarOrExpr struct {
	Left  *GrammarAndExpr   `parser:"@@"`
	Right []*GrammarOrRight `parser:"@@*"`
}

GrammarOrExpr represents OR expression.

type GrammarOrRight

type GrammarOrRight struct {
	Or    string          `parser:"@'OR'"`
	Right *GrammarAndExpr `parser:"@@"`
}

GrammarOrRight represents right side of OR.

type GrammarOrderByTail

type GrammarOrderByTail struct {
	DirOnly   *string                  `parser:"  @('ASC'|'DESC')"`
	WithIdent *GrammarOrderByWithIdent `parser:"| @@ "`
}

GrammarOrderByTail represents the tail of ORDER BY clause, Identifier with optional direction or direction only.

type GrammarOrderByWithIdent

type GrammarOrderByWithIdent struct {
	Identifier *GrammarIdentifierPath `parser:"@@"`
	Direction  *string                `parser:"@( 'ASC' | 'DESC' )?"`
}

GrammarOrderByWithIdent represents ORDER BY with identifier and optional direction.

type GrammarOrderKey added in v0.12.0

type GrammarOrderKey struct {
	Expression *GrammarExpression
	Descending bool
	NullsFirst bool
}

GrammarOrderKey describes one typed measure ordering expression.

type GrammarPredicate

type GrammarPredicate struct {
	Paren  *GrammarOrExpr          `parser:"  '(' @@ ')'"`
	Binary *GrammarBinaryPredicate `parser:"| @@"`
	In     *GrammarInPredicate     `parser:"| @@"`
	Having *GrammarHavingPredicate `parser:"| @@"`
}

GrammarPredicate represents a predicate.

type GrammarProjection

type GrammarProjection struct {
	All     bool                   `parser:"  @'*'"`
	Empty   bool                   `parser:"| @'(' ')'"`
	TopN    *GrammarTopNProjection `parser:"| 'TOP' @@"`
	Columns []*GrammarColumn       `parser:"| @@ ( ',' @@ )*"`
}

GrammarProjection represents projection in SELECT.

type GrammarSelectOrderByClause

type GrammarSelectOrderByClause struct {
	Order string             `parser:"@'ORDER'"`
	By    string             `parser:"@'BY'"`
	Tail  GrammarOrderByTail `parser:"@@"`
	Keys  []*GrammarOrderKey
}

GrammarSelectOrderByClause represents ORDER BY clause in SELECT statement.

type GrammarSelectStatement

type GrammarSelectStatement struct {
	Pos            lexer.Position
	Select         string                    `parser:"@'SELECT'"`
	Distinct       bool                      `parser:"@'DISTINCT'?"`
	Projection     *GrammarProjection        `parser:"@@"`
	From           *GrammarFromClause        `parser:"@@"`
	Time           *GrammarTimeClause        `parser:"@@?"`
	Where          *GrammarSelectWhereClause `parser:"@@?"`
	GroupBy        *GrammarGroupByClause     `parser:"@@?"`
	Having         *GrammarHavingClause
	OrderBy        *GrammarSelectOrderByClause `parser:"@@?"`
	WithQueryTrace *GrammarWithTraceClause     `parser:"@@?"`
	Limit          *GrammarLimitClause         `parser:"@@?"`
	Offset         *GrammarOffsetClause        `parser:"@@?"`
}

GrammarSelectStatement represents a SELECT statement in Participle grammar.

type GrammarSelectWhereClause

type GrammarSelectWhereClause struct {
	Where string         `parser:"@'WHERE'"`
	Expr  *GrammarOrExpr `parser:"@@"`
	// Expression is populated only by the typed measure WHERE parser.
	Expression *GrammarExpression
}

GrammarSelectWhereClause represents WHERE clause.

type GrammarStageClause

type GrammarStageClause struct {
	On      string   `parser:"@'ON'"`
	LParen  bool     `parser:"@'('?"`
	Stages  []string `parser:"@Ident ( ',' @Ident )*"`
	RParen  bool     `parser:"@')'?"`
	Stages2 string   `parser:"@'STAGES'"`
}

GrammarStageClause represents STAGES clause.

type GrammarTimeBetween

type GrammarTimeBetween struct {
	Between string            `parser:"@'BETWEEN'"`
	Begin   *GrammarTimeValue `parser:"@@"`
	And     string            `parser:"@'AND'"`
	End     *GrammarTimeValue `parser:"@@"`
}

GrammarTimeBetween represents TIME BETWEEN.

type GrammarTimeBucket added in v0.12.0

type GrammarTimeBucket struct {
	TimeBucket string  `parser:"@'TIME_BUCKET'"`
	LParen     string  `parser:"'('"`
	Width      *string `parser:"@String?"`
	RParen     string  `parser:"')'"`
}

GrammarTimeBucket represents TIME_BUCKET(<duration>). Width is optional; an empty width defers to the measure's own interval (design §5.3).

type GrammarTimeClause

type GrammarTimeClause struct {
	Time       string              `parser:"@'TIME'"`
	Comparator *string             `parser:"(  @( '=' | '>' | '<' | '>=' | '<=' )"`
	Value      *GrammarTimeValue   `parser:"   @@"`
	Between    *GrammarTimeBetween `parser:"| @@ )"`
}

GrammarTimeClause represents TIME clause.

type GrammarTimeValue

type GrammarTimeValue struct {
	String  *string `parser:"  @String"`
	Integer *int64  `parser:"| @Int"`
	Param   bool    `parser:"| @Param"`
	// ParamIndex is the placeholder's positional index, assigned by Prepare and
	// meaningful only when Param is true. It keys the per-request bound overlay.
	ParamIndex int
}

GrammarTimeValue represents a time value (string, integer, or a `?` placeholder).

func (*GrammarTimeValue) ToString

func (g *GrammarTimeValue) ToString() string

ToString converts time value to string representation.

type GrammarTopNAggregateByClause

type GrammarTopNAggregateByClause struct {
	Aggregate string                        `parser:"@'AGGREGATE'"`
	By        string                        `parser:"@'BY'"`
	Function  *GrammarTopNAggregateFunction `parser:"@@"`
}

GrammarTopNAggregateByClause represents AGGREGATE BY clause.

type GrammarTopNAggregateFunction

type GrammarTopNAggregateFunction struct {
	Function string `parser:"@('SUM'|'MEAN'|'AVG'|'COUNT'|'MAX'|'MIN')"`
}

GrammarTopNAggregateFunction represents aggregate functions without column (for TOP N).

type GrammarTopNOrderByClause

type GrammarTopNOrderByClause struct {
	Order string  `parser:"@'ORDER'"`
	By    string  `parser:"@'BY'"`
	Dir   *string `parser:"@('ASC'|'DESC')?"`
}

GrammarTopNOrderByClause represents ORDER BY clause in TOP N statement.

type GrammarTopNProjection

type GrammarTopNProjection struct {
	N            int  `parser:"( @Int"`
	NParam       bool `parser:"| @Param )"`
	NParamIndex  int
	OrderField   *GrammarIdentifierPath `parser:"@@"`
	Direction    *string                `parser:"@('ASC'|'DESC')?"`
	OtherColumns []*GrammarColumn       `parser:"  ( ',' @@ ( ',' @@ )* )?"`
}

GrammarTopNProjection represents TOP N projection.

type GrammarTopNStatement

type GrammarTopNStatement struct {
	Pos            lexer.Position
	Show           string `parser:"@'SHOW'"`
	Top            string `parser:"@'TOP'"`
	N              int    `parser:"( @Int"`
	NParam         bool   `parser:"| @Param )"`
	NParamIndex    int
	From           *GrammarFromClause            `parser:"@@"`
	Time           *GrammarTimeClause            `parser:"@@?"`
	Where          *GrammarTopNWhereClause       `parser:"@@?"`
	AggregateBy    *GrammarTopNAggregateByClause `parser:"@@?"`
	OrderBy        *GrammarTopNOrderByClause     `parser:"@@?"`
	WithQueryTrace *GrammarWithTraceClause       `parser:"@@?"`
}

GrammarTopNStatement represents a SHOW TOP N statement.

type GrammarTopNWhereClause

type GrammarTopNWhereClause struct {
	Where string          `parser:"@'WHERE'"`
	Expr  *GrammarAndExpr `parser:"@@"`
}

GrammarTopNWhereClause represents WHERE clause in TOP N.

type GrammarValue

type GrammarValue struct {
	String  *string          `parser:"  @String"`
	Integer *int64           `parser:"| @Int"`
	Null    bool             `parser:"| @'NULL'"`
	Now     *GrammarNowValue `parser:"| @@"`
	Param   bool             `parser:"| @Param"`
	// ParamIndex is the placeholder's positional index, assigned by Prepare and
	// meaningful only when Param is true. It keys the per-request bound overlay.
	ParamIndex int
}

GrammarValue represents a value.

type GrammarWithTraceClause

type GrammarWithTraceClause struct {
	With       string `parser:"@'WITH'"`
	QueryTrace string `parser:"@'QUERY_TRACE'"`
}

GrammarWithTraceClause represents WITH QUERY_TRACE clause.

type MeasureExecution added in v0.12.0

type MeasureExecution struct {
	Request *measurev1.QueryRequest
	Plan    *ql.RawPlan
}

MeasureExecution is one fresh binding of a measure template. A nil Plan preserves the legacy native execution and output contract.

type MeasureSource added in v0.12.0

type MeasureSource struct {
	Group string
	Name  string
}

MeasureSource identifies one explicitly named measure schema dependency.

type MeasureTemplate added in v0.12.0

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

MeasureTemplate contains immutable, schema-resolved measure planning metadata. Each Bind creates independent requests and operators; no parameter or clock value is retained.

func (*MeasureTemplate) Bind added in v0.12.0

func (m *MeasureTemplate) Bind(bound *BoundQuery, now time.Time) (*MeasureExecution, error)

Bind instantiates a template with fresh parameter values and a single execution clock.

func (*MeasureTemplate) BindParams added in v0.12.0

func (m *MeasureTemplate) BindParams(params []*modelv1.TagValue, now time.Time) (*MeasureExecution, error)

BindParams binds against the template's own immutable prepared statement. It remains valid when the independent prepared-statement cache evicts or reparses a query.

func (*MeasureTemplate) EstimatedSize added in v0.12.0

func (m *MeasureTemplate) EstimatedSize() int

EstimatedSize estimates the retained Go object graph, including shared syntax. Shared pointers and backing arrays are counted once; global protobuf runtime descriptors are excluded because the template does not own them.

type PreparedStatement added in v0.11.0

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

PreparedStatement is an immutable, reusable parsed query. It is safe to cache and to Bind concurrently: Prepare numbers the placeholders once, and Bind never mutates the template — the bound values live in a per-request overlay.

func Prepare added in v0.11.0

func Prepare(query string) (*PreparedStatement, error)

Prepare parses a query and numbers its `?` placeholders so it can be bound repeatedly with different parameters without re-parsing.

func (*PreparedStatement) Bind added in v0.11.0

func (ps *PreparedStatement) Bind(params []*modelv1.TagValue) (*BoundQuery, error)

Bind resolves params against the statement's placeholders and returns a per-request BoundQuery, leaving the template untouched, so a statement may be bound repeatedly and concurrently. Parameter positions in errors are 1-based, matching BindParams.

func (*PreparedStatement) EstimatedSize added in v0.11.0

func (ps *PreparedStatement) EstimatedSize() int

EstimatedSize returns an approximate in-memory byte footprint of the prepared statement — its parsed grammar template and placeholder specs. It is a heuristic for cache byte-accounting (a deduplicated reflection walk of the object graph), not an exact measurement, and is called off the hot path.

func (*PreparedStatement) MeasureSources added in v0.12.0

func (ps *PreparedStatement) MeasureSources() []MeasureSource

MeasureSources reports measure sources in statement order, including repeated groups. Non-measure statements have no measure dependencies.

func (*PreparedStatement) NumPlaceholders added in v0.11.0

func (ps *PreparedStatement) NumPlaceholders() int

NumPlaceholders reports how many `?` placeholders the statement carries. A zero count means a literal query with no reusable parameters.

func (*PreparedStatement) QueryText added in v0.12.0

func (ps *PreparedStatement) QueryText() string

QueryText returns the exact SQL text used to prepare the statement.

type QueryType

type QueryType int

QueryType represents the type of query.

const (
	QueryTypeMeasure QueryType = iota
	QueryTypeStream
	QueryTypeTrace
	QueryTypeProperty
	QueryTypeTopN
)

Supported query types.

func (QueryType) String

func (t QueryType) String() string

type SchemaSource added in v0.12.0

type SchemaSource interface {
	Measure(group, name string) (*databasev1.Measure, bool)
	Stream(group, name string) (*databasev1.Stream, bool)
	Trace(group, name string) (*databasev1.Trace, bool)
}

SchemaSource resolves resource schemas from a local, watch-fed cache, such as the liaison's entity repository. A miss reports false and the Transformer falls back to the schema registry, which covers the window before a newly created resource's watch event arrives.

Returned schemas are shared with the cache and must be treated as read-only.

type TransformResult

type TransformResult struct {
	QueryRequest proto.Message
	Original     *Grammar
	Type         QueryType
	// Offset is how many leading rows of the response to skip, for a query whose native request has no offset of its own
	// (a property query): the request then asks for offset+limit rows and the caller drops the first Offset.
	Offset uint32
	// Empty is set when a stream, trace or property statement asks for no row at all (LIMIT 0). Measure keeps its pinned
	// legacy contract, where LIMIT 0 is the default page. The request must not be executed as it is: a native
	// request reads a limit of 0 as "the default limit" and would return a full default page.
	Empty bool
}

TransformResult is the result of transforming a Grammar into a query request.

type Transformer

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

Transformer transforms a Grammar into a native query request.

func NewTransformer

func NewTransformer(registry metadata.Repo) *Transformer

NewTransformer creates a new Transformer with the given schema registry.

func NewTransformerWithSource added in v0.12.0

func NewTransformerWithSource(registry metadata.Repo, source SchemaSource) *Transformer

NewTransformerWithSource creates a Transformer that reads measure, stream and trace schemas from source first and falls back to registry on a miss. Reading locally avoids the registry's per-call fan-out to every metadata node.

func (*Transformer) CompileMeasure added in v0.12.0

func (t *Transformer) CompileMeasure(ctx context.Context, statement *PreparedStatement) (*MeasureTemplate, error)

CompileMeasure resolves a prepared measure query against a read-only schema snapshot. Non-measure queries return a nil template and retain their existing dispatch.

func (*Transformer) CompileMeasureWithSchemas added in v0.12.0

func (t *Transformer) CompileMeasureWithSchemas(
	ctx context.Context, statement *PreparedStatement, schemas map[MeasureSource]*databasev1.Measure,
) (*MeasureTemplate, error)

CompileMeasureWithSchemas resolves a query using only the supplied schema snapshots. Missing snapshots are errors; this entry point never falls back to a registry.

func (*Transformer) Transform

func (t *Transformer) Transform(ctx context.Context, grammar *Grammar) (*TransformResult, error)

Transform transforms a Grammar into a native query request. The grammar must be free of unbound placeholders: either a literal query or one bound in place by BindParams. Use TransformBound for a reusable prepared statement.

func (*Transformer) TransformBound added in v0.11.0

func (t *Transformer) TransformBound(ctx context.Context, bq *BoundQuery) (*TransformResult, error)

TransformBound transforms a bound prepared statement, reading parameter values from the per-request overlay instead of the immutable template.

Jump to

Keyboard shortcuts

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