clickhouse

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TAG_FUNCTION_NODE_TYPE                  = "node_type"
	TAG_FUNCTION_ICON_ID                    = "icon_id"
	TAG_FUNCTION_MASK                       = "mask"
	TAG_FUNCTION_TIME                       = "time"
	TAG_FUNCTION_TO_UNIX_TIMESTAMP_64_MICRO = "toUnixTimestamp64Micro"
	TAG_FUNCTION_TO_UNIX_TIMESTAMP          = "toUnixTimestamp"
	TAG_FUNCTION_TO_STRING                  = "toString"
	TAG_FUNCTION_IF                         = "if"
	TAG_FUNCTION_UNIQ                       = "uniq"
	TAG_FUNCTION_ANY                        = "any"
	TAG_FUNCTION_TOPK                       = "topK"
	TAG_FUNCTION_NEW_TAG                    = "newTag"
	TAG_FUNCTION_ENUM                       = "enum"
	TAG_FUNCTION_FAST_FILTER                = "FastFilter"
	TAG_FUNCTION_FAST_TRANS                 = "FastTrans"
)
View Source
const INTERVAL_1D = 86400

Variables

View Source
var DEFAULT_LIMIT = "10000"
View Source
var INVALID_PROMETHEUS_SUBQUERY_CACHE_ENTRY = "-1"
View Source
var TIME_FILL_LIMIT_DEFAULT = 20

Functions

func ColumnNameSwap

func ColumnNameSwap(args []interface{}) func(result *common.Result) error

func FormatInnerTime

func FormatInnerTime(m *view.Model)

func FormatLimit

func FormatLimit(m *view.Model)

func FormatModel

func FormatModel(m *view.Model)

func GetDatabases

func GetDatabases() *common.Result

func GetDefaultAlias

func GetDefaultAlias(name string, args []string) string

func GetMetricIDFilter

func GetMetricIDFilter(db, table string) (view.Node, error)

func GetNotNullFilter

func GetNotNullFilter(name string, asTagMap map[string]string, db, table string) (view.Node, bool)

func GetPrometheusAllTagTranslator

func GetPrometheusAllTagTranslator(table string) (string, string, error)

func GetPrometheusFilter

func GetPrometheusFilter(promTag, table, op, value string) (string, error)

func GetPrometheusGroup

func GetPrometheusGroup(name, table string, asTagMap map[string]string) string

func GetPrometheusNotNullFilter

func GetPrometheusNotNullFilter(name, table string, asTagMap map[string]string) (view.Node, bool)

func GetPrometheusSingleTagTranslator

func GetPrometheusSingleTagTranslator(tag, table string) (string, string, error)

func GetRemoteReadFilter

func GetRemoteReadFilter(promTag, table, op, value, originFilter string, e *CHEngine) (string, error)

func GetTables

func GetTables(db string, ctx context.Context) *common.Result

func GetVirtualTableFilter

func GetVirtualTableFilter(db, table string) (view.Node, bool)

func LoadDbDescriptions

func LoadDbDescriptions(dbDescriptions map[string]interface{}) error

func MacTranslate

func MacTranslate(args []interface{}) func(result *common.Result) error

func TimeFill

func TimeFill(args []interface{}) func(result *common.Result) error

func TransWhereTagFunction

func TransWhereTagFunction(db string, name string, args []string) (filter string)

Types

type AggFunction

type AggFunction struct {
	// 指标量内容
	Metrics *metrics.Metrics
	// 解析获得的参数
	Name              string
	Args              []string
	Alias             string
	IsDerivative      bool
	DerivativeArgs    []string
	DerivativeGroupBy []string
}

func (*AggFunction) Format

func (f *AggFunction) Format(m *view.Model)

func (*AggFunction) FormatInnerTag

func (f *AggFunction) FormatInnerTag(m *view.Model) (innerAlias string)

func (*AggFunction) SetAlias

func (f *AggFunction) SetAlias(alias string)

func (*AggFunction) Trans

func (f *AggFunction) Trans(m *view.Model) view.Node

type BinaryFunction

type BinaryFunction struct {
	Name      string
	Functions []Function
	Alias     string
}

func GetBinaryFunc

func GetBinaryFunc(name string, args []Function) (*BinaryFunction, error)

func (*BinaryFunction) Format

func (f *BinaryFunction) Format(m *view.Model)

func (*BinaryFunction) SetAlias

func (f *BinaryFunction) SetAlias(alias string)

func (*BinaryFunction) Trans

func (f *BinaryFunction) Trans(m *view.Model) view.Node

type CHEngine

type CHEngine struct {
	Model              *view.Model
	Statements         []Statement
	DB                 string
	Table              string
	DataSource         string
	AsTagMap           map[string]string
	ColumnSchemas      []*common.ColumnSchema
	View               *view.View
	Context            context.Context
	TargetLabelFilters []TargetLabelFilter
	NoPreWhere         bool
	IsDerivative       bool
	DerivativeGroupBy  []string
}

func (*CHEngine) AddGroup

func (e *CHEngine) AddGroup(group string) error

func (*CHEngine) AddTable

func (e *CHEngine) AddTable(table string)

func (*CHEngine) AddTag

func (e *CHEngine) AddTag(tag string, alias string) (string, error)

func (*CHEngine) ExecuteQuery

func (e *CHEngine) ExecuteQuery(args *common.QuerierParams) (*common.Result, map[string]interface{}, error)

func (*CHEngine) Init

func (e *CHEngine) Init()

func (*CHEngine) ParseShowSql

func (e *CHEngine) ParseShowSql(sql string) (*common.Result, []string, bool, error)

func (*CHEngine) ParseSlimitSql

func (e *CHEngine) ParseSlimitSql(sql string) (string, map[string]func(*common.Result) error, map[string]*common.ColumnSchema, error)

func (*CHEngine) ParseWithSql

func (e *CHEngine) ParseWithSql(sql string) (string, map[string]func(*common.Result) error, map[string]*common.ColumnSchema, error)

func (*CHEngine) QuerySlimitSql

func (e *CHEngine) QuerySlimitSql(sql string, args *common.QuerierParams) (*common.Result, map[string]interface{}, error)

func (*CHEngine) QueryWithSql

func (e *CHEngine) QueryWithSql(sql string, args *common.QuerierParams) (*common.Result, map[string]interface{}, error)

func (*CHEngine) SetLevelFlag

func (e *CHEngine) SetLevelFlag(flag int)

func (*CHEngine) ToSQLString

func (e *CHEngine) ToSQLString() string

原始sql转为clickhouse-sql

func (*CHEngine) TransDerivativeGroupBy

func (e *CHEngine) TransDerivativeGroupBy(groups sqlparser.GroupBy) error

func (*CHEngine) TransFrom

func (e *CHEngine) TransFrom(froms sqlparser.TableExprs) error

func (*CHEngine) TransGroupBy

func (e *CHEngine) TransGroupBy(groups sqlparser.GroupBy) error

func (*CHEngine) TransHaving

func (e *CHEngine) TransHaving(node *sqlparser.Where) error

func (*CHEngine) TransLimit

func (e *CHEngine) TransLimit(limit *sqlparser.Limit) error

func (*CHEngine) TransOrderBy

func (e *CHEngine) TransOrderBy(orders sqlparser.OrderBy) error

func (*CHEngine) TransPrometheusTargetIDFilter

func (e *CHEngine) TransPrometheusTargetIDFilter(expr view.Node) (view.Node, error)

func (*CHEngine) TransSelect

func (e *CHEngine) TransSelect(tags sqlparser.SelectExprs) error

func (*CHEngine) TransWhere

func (e *CHEngine) TransWhere(node *sqlparser.Where) error

type Callback

type Callback struct {
	Args     []interface{}
	Function func([]interface{}) func(*common.Result) error
	Column   string
}

func (*Callback) Format

func (c *Callback) Format(m *view.Model)

type Field

type Field struct {
	Value string
}

func (*Field) Format

func (f *Field) Format(m *view.Model)

func (*Field) SetAlias

func (f *Field) SetAlias(alias string)

func (*Field) Trans

func (f *Field) Trans(m *view.Model) view.Node

type FieldFunction

type FieldFunction interface {
	Function
}

func GetFieldFunc

func GetFieldFunc(name string) (FieldFunction, error)

type Function

type Function interface {
	Statement
	Trans(m *view.Model) view.Node
	SetAlias(alias string)
}

type GroupTag

type GroupTag struct {
	Value    string
	Alias    string
	Withs    []view.Node
	AsTagMap map[string]string
}

func (*GroupTag) Format

func (g *GroupTag) Format(m *view.Model)

type Having

type Having struct {
	Where
}

func (*Having) Format

func (h *Having) Format(m *view.Model)

type PrometheusSubqueryCache

type PrometheusSubqueryCache struct {
	PrometheusSubqueryCache *lru.Cache[string, common.EntryValue]
}

func GetPrometheusSubqueryCache

func GetPrometheusSubqueryCache() *PrometheusSubqueryCache

type SelectTag

type SelectTag struct {
	Value string
	Alias string
	Flag  int
	Withs []view.Node
}

func (*SelectTag) Format

func (t *SelectTag) Format(m *view.Model)

type Statement

type Statement interface {
	Format(*view.Model)
}

翻译单元,翻译结果写入view.Model

func GetAggFunc

func GetAggFunc(name string, args []string, alias string, db string, table string, ctx context.Context, isDerivative bool, derivativeGroupBy []string, derivativeArgs []string) (Statement, int, string, error)

func GetDefaultTag

func GetDefaultTag(name string, alias string) Statement

func GetGroup

func GetGroup(name string, asTagMap map[string]string, db, table string) ([]Statement, error)

func GetMetricsTag

func GetMetricsTag(name string, alias string, db string, table string, ctx context.Context) (Statement, error)

func GetTagFunction

func GetTagFunction(name string, args []string, alias, db, table string) (Statement, error)

func GetTagTranslator

func GetTagTranslator(name, alias, db, table string) ([]Statement, string, error)

func GetTopKTrans

func GetTopKTrans(name string, args []string, alias string, db string, table string, ctx context.Context) (Statement, int, string, error)

type Table

type Table struct {
	Value string
}

func (*Table) Format

func (t *Table) Format(m *view.Model)

type TagFunction

type TagFunction struct {
	Name  string
	Args  []string
	Alias string
	Withs []view.Node
	Value string
	DB    string
	Table string
}

func (*TagFunction) Check

func (f *TagFunction) Check() error

func (*TagFunction) Format

func (f *TagFunction) Format(m *view.Model)

func (*TagFunction) SetAlias

func (f *TagFunction) SetAlias(alias string)

func (*TagFunction) Trans

func (f *TagFunction) Trans(m *view.Model) view.Node

type TargetLabelFilter

type TargetLabelFilter struct {
	OriginFilter string
	TransFilter  string
}

type Time

type Time struct {
	Args       []string
	Alias      string
	Withs      []view.Node
	TimeField  string
	Interval   int
	WindowSize int
	Offset     int
	Fill       string
}

func (*Time) Format

func (t *Time) Format(m *view.Model)

func (*Time) Trans

func (t *Time) Trans(m *view.Model) error

type TimeIntervalField

type TimeIntervalField struct {
	FieldFunction
}

func (*TimeIntervalField) Format

func (f *TimeIntervalField) Format(m *view.Model)

func (*TimeIntervalField) SetAlias

func (f *TimeIntervalField) SetAlias(alias string)

func (*TimeIntervalField) Trans

func (f *TimeIntervalField) Trans(m *view.Model) view.Node

type TimeTag

type TimeTag struct {
	Value string
}

func (*TimeTag) Trans

func (t *TimeTag) Trans(expr sqlparser.Expr, w *Where, e *CHEngine) (view.Node, error)

type Where

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

func (*Where) Format

func (w *Where) Format(m *view.Model)

type WhereFunction

type WhereFunction struct {
	Function view.Node
	Value    string
}

func (*WhereFunction) Trans

func (f *WhereFunction) Trans(expr sqlparser.Expr, w *Where, asTagMap map[string]string, db, table string) (view.Node, error)

type WhereStatement

type WhereStatement interface {
	Trans(sqlparser.Expr, *Where, *CHEngine) (view.Node, error)
}

func GetWhere

func GetWhere(name, value string) WhereStatement

type WhereTag

type WhereTag struct {
	Tag   string
	Value string
}

func (*WhereTag) Trans

func (t *WhereTag) Trans(expr sqlparser.Expr, w *Where, e *CHEngine) (view.Node, error)

Directories

Path Synopsis
packet_batch module

Jump to

Keyboard shortcuts

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