metricssqlparser

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

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.

Jump to

Keyboard shortcuts

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