metricssqlparser

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSQLFilter added in v0.49.0

func ParseSQLFilter(sql string) (*metricsview.Expression, error)

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) Rewrite added in v0.48.0

func (c *Compiler) Rewrite(ctx context.Context, sql string) (*metricsview.Query, error)

Rewrite parses a metrics SQL query and compiles it to a metricview.Query. It uses 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.

Jump to

Keyboard shortcuts

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