Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctrl *runtime.Controller, instanceID string, claims *runtime.SecurityClaims, priority int) *Compiler
New returns a compiler and created a tidb parser object. The instantiated parser object and thus compiler is not goroutine safe and not lightweight. It is better to keep it in a single goroutine, and reuse it if possible.
func (*Compiler) Compile ¶
func (c *Compiler) Compile(ctx context.Context, sql string) (string, string, []*runtimev1.ResourceName, error)
Compile parses a metrics SQL query and compiles it to a regular SQL query. It uses tidb parser(which is a MySQL compliant parser) and transforms over the generated AST to generate regular SQL 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.