Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFilter ¶
func ParseFilter(sql string) (*metricsview.Expression, error)
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler is responsible for parsing metrics SQL queries into metricsview.Query objects.
Internally, it creates and re-uses a TiDB parser object. It's not lightweight, so re-use the Compiler when possible. However, note that it is not concurrency safe.
func (*Compiler) Parse ¶
Parse parses a metrics SQL query into a metricview.Query. It uses the tidb parser (which is a MySQL compliant parser) and transforms over the generated AST to generate query. We use MySQL's ANSI SQL Mode to conform more closely to standard SQL.
Whenever adding transform method over new node type also look at its `Restore` method to get an idea how it can be parsed into a SQL query.
type CompilerOptions ¶
type CompilerOptions struct {
// GetMetricsView is a callback to lookup a referenced metrics view.
// It is required for parsing full queries, but optional when parsing only filters.
GetMetricsView func(ctx context.Context, name string) (*runtimev1.Resource, error)
// GetTimestamps is a callback to resolve timestamps for a given time dimension.
// It is optional, but if not provided, queries that use rilltime expressions will error.
// TODO: Ideally we should replace this with support for rilltime expressions in *metricsview.Expression itself, so evaluation can be delayed until query execution.
GetTimestamps func(ctx context.Context, mv *runtimev1.Resource, timeDim string) (metricsview.TimestampsResult, error)
}
CompilerOptions provide options for the Compiler.