types

package
Version: v0.0.0-...-98b08c6 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArithmeticCol

type ArithmeticCol struct {
	Column []Column   `json:"column"`
	Alias  string     `json:"alias"`
	Type   ColumnType `json:"type"`
}

func (*ArithmeticCol) GetAlias

func (col *ArithmeticCol) GetAlias() string

func (*ArithmeticCol) GetExpression

func (col *ArithmeticCol) GetExpression() string

type ArithmeticOperatorType

type ArithmeticOperatorType string
const (
	ArithmeticOperatorTypeAdd      ArithmeticOperatorType = "+"
	ArithmeticOperatorTypeSubtract ArithmeticOperatorType = "-"
	ArithmeticOperatorTypeMultiply ArithmeticOperatorType = "*"
	ArithmeticOperatorTypeDivide   ArithmeticOperatorType = "/"
)

type Column

type Column interface {
	GetExpression() string
	GetAlias() string
}

type ColumnType

type ColumnType string
const (
	ColumnTypeValue         ColumnType = "value"
	ColumnTypeCount         ColumnType = "count"
	ColumnTypeDistinctCount ColumnType = "distinct_count"
	ColumnTypeSum           ColumnType = "sum"
	ColumnTypeAdd           ColumnType = "add"
	ColumnTypeSubtract      ColumnType = "subtract"
	ColumnTypeMultiply      ColumnType = "multiply"
	ColumnTypeDivide        ColumnType = "divide"
	ColumnTypePost          ColumnType = "post"
	ColumnTypeExpression    ColumnType = "expression"
)

type DataSource

type DataSource struct {
	Type DataSourceType `json:"type"`
	Name string         `json:"name"`
}

func (*DataSource) Statement

func (d *DataSource) Statement() (string, error)

type DataSourceType

type DataSourceType string
const (
	DataSourceTypeUnknown    DataSourceType = "DATA_SOURCE_UNKNOWN"
	DataSourceTypeClickHouse DataSourceType = "DATA_SOURCE_CLICKHOUSE"
	DataSourceTypeDruid      DataSourceType = "DATA_SOURCE_DRUID"
	DataSourceTypeKylin      DataSourceType = "DATA_SOURCE_KYLIN"
	DataSourceTypePresto     DataSourceType = "DATA_SOURCE_PRESTO"
)

func EnumToDataSourceType

func EnumToDataSourceType(d proto.DATA_SOURCE_TYPE) DataSourceType

func (DataSourceType) ToEnum

type Dimension

type Dimension struct {
	Table     string `json:"table"`
	Name      string `json:"name"`
	FieldName string `json:"field_name"`
}

func ProtoToDimension

func ProtoToDimension(d *proto.Dimension) *Dimension

func (*Dimension) Alias

func (d *Dimension) Alias() (string, error)

func (*Dimension) Expression

func (d *Dimension) Expression() (string, error)

func (*Dimension) Statement

func (d *Dimension) Statement() (string, error)

func (*Dimension) ToProto

func (d *Dimension) ToProto() *proto.Dimension

type ExpressionCol

type ExpressionCol struct {
	Expression string `json:"expression"`
	Alias      string `json:"alias"`
}

func (*ExpressionCol) GetAlias

func (col *ExpressionCol) GetAlias() string

func (*ExpressionCol) GetExpression

func (col *ExpressionCol) GetExpression() string

type Filter

type Filter struct {
	OperatorType FilterOperatorType `json:"operator_type"`
	ValueType    ValueType          `json:"value_type"`
	Name         string             `json:"name"`
	Value        []interface{}      `json:"value"`
	Children     []*Filter          `json:"children"`
}

func ProtoToFilter

func ProtoToFilter(m *proto.Filter) *Filter

func (*Filter) Alias

func (f *Filter) Alias() (string, error)

func (*Filter) Expression

func (f *Filter) Expression() (string, error)

func (*Filter) Statement

func (f *Filter) Statement() (string, error)

func (*Filter) ToProto

func (f *Filter) ToProto() *proto.Filter

type FilterOperatorType

type FilterOperatorType string
const (
	FilterOperatorTypeUnknown       FilterOperatorType = "FILTER_OPERATOR_UNKNOWN"
	FilterOperatorTypeIn            FilterOperatorType = "FILTER_OPERATOR_IN"
	FilterOperatorTypeNotIn         FilterOperatorType = "FILTER_OPERATOR_NOT_IN"
	FilterOperatorTypeLessEquals    FilterOperatorType = "FILTER_OPERATOR_LESS_EQUALS"
	FilterOperatorTypeLess          FilterOperatorType = "FILTER_OPERATOR_LESS"
	FilterOperatorTypeGreaterEquals FilterOperatorType = "FILTER_OPERATOR_GREATER_EQUALS"
	FilterOperatorTypeGreater       FilterOperatorType = "FILTER_OPERATOR_GREATER"
	FilterOperatorTypeLike          FilterOperatorType = "FILTER_OPERATOR_LIKE"
	FilterOperatorTypeExpression    FilterOperatorType = "FILTER_OPERATOR_EXTENSION"
	FilterOperatorTypeAnd           FilterOperatorType = "FILTER_OPERATOR_AND"
	FilterOperatorTypeOr            FilterOperatorType = "FILTER_OPERATOR_OR"
)

func (FilterOperatorType) IsTree

func (f FilterOperatorType) IsTree() bool

func (FilterOperatorType) ToEnum

type Item

type Item struct {
	Values map[string]string `json:"values"`
}

func ProtoToItem

func ProtoToItem(item *proto.Item) *Item

func (*Item) ToProto

func (item *Item) ToProto() *proto.Item

type Join

type Join struct {
	Database1 string    `json:"data_base1"`
	Database2 string    `json:"data_base2"`
	Table1    string    `json:"table1"`
	Table2    string    `json:"table2"`
	On        []*JoinOn `json:"on"`
	Filters   []*Filter `json:"filters"`
}

func ProtoToJoin

func ProtoToJoin(j *proto.Join) *Join

func (*Join) ToProto

func (j *Join) ToProto() *proto.Join

type JoinOn

type JoinOn struct {
	Key1 string `json:"key1"`
	Key2 string `json:"key2"`
}

type Limit

type Limit struct {
	Limit  uint64 `json:"limit"`
	Offset uint64 `json:"offset"`
}

func ProtoToLimit

func ProtoToLimit(l *proto.Limit) *Limit

func (*Limit) ToProto

func (l *Limit) ToProto() *proto.Limit

type Metric

type Metric struct {
	Type      MetricType `json:"type"`
	Table     string     `json:"table"`
	Name      string     `json:"name"`
	FieldName string     `json:"field_name"`
	Children  []*Metric  `json:"children"`
}

func ProtoToMetric

func ProtoToMetric(m *proto.Metric) *Metric

func (*Metric) Alias

func (m *Metric) Alias() (string, error)

func (*Metric) Expression

func (m *Metric) Expression() (string, error)

func (*Metric) Statement

func (m *Metric) Statement() (string, error)

func (*Metric) ToProto

func (m *Metric) ToProto() *proto.Metric

type MetricType

type MetricType string
const (
	MetricTypeUnknown       MetricType = "METRIC_UNKNOWN"        // invalid type.
	MetricTypeValue         MetricType = "METRIC_VALUE"          // single type. eg: 原始值指标
	MetricTypeCount         MetricType = "METRIC_COUNT"          // single type. eg: 计数指标
	MetricTypeDistinctCount MetricType = "METRIC_DISTINCT_COUNT" // single type. eg: 去重计数指标
	MetricTypeSum           MetricType = "METRIC_SUM"            // single type. eg: 求和指标
	MetricTypeAdd           MetricType = "METRIC_ADD"            // composition type eg: 相加指标
	MetricTypeSubtract      MetricType = "METRIC_SUBTRACT"       // composition type eg: 相乘指标
	MetricTypeMultiply      MetricType = "METRIC_MULTIPLY"       // composition type eg: 相减指标
	MetricTypeDivide        MetricType = "METRIC_DIVIDE"         // composition type.eg: 相除指标
	MetricTypeExpression    MetricType = "METRIC_EXPRESSION"     // single type. eg: 表达式
	MetricTypePost          MetricType = "METRIC_POST"           // composition type, unsupported now
)

func EnumToMetricType

func EnumToMetricType(m proto.METRIC_TYPE) MetricType

func (MetricType) ToEnum

func (m MetricType) ToEnum() proto.METRIC_TYPE

type OrderBy

type OrderBy struct {
	Name      string             `json:"name"`
	Direction OrderDirectionType `json:"direction"`
}

func ProtoToOrderBy

func ProtoToOrderBy(o *proto.OrderBy) *OrderBy

func (*OrderBy) Alias

func (o *OrderBy) Alias() (string, error)

func (*OrderBy) Expression

func (o *OrderBy) Expression() (string, error)

func (*OrderBy) Statement

func (o *OrderBy) Statement() (string, error)

func (*OrderBy) ToProto

func (o *OrderBy) ToProto() *proto.OrderBy

type OrderDirectionType

type OrderDirectionType string
const (
	OrderDirectionTypeUnknown    OrderDirectionType = "ORDER_DIRECTION_UNKNOWN"
	OrderDirectionTypeAscending  OrderDirectionType = "ORDER_DIRECTION_ASCENDING"
	OrderDirectionTypeDescending OrderDirectionType = "ORDER_DIRECTION_DESCENDING"
)

func (OrderDirectionType) ToEnum

type Query

type Query struct {
	DataSetName  string        `json:"data_set_name"`
	TimeInterval *TimeInterval `json:"time_interval"`
	Metrics      []string      `json:"metrics"`
	Dimensions   []string      `json:"dimensions"`
	Filters      []*Filter     `json:"filters"`
	Orders       []*OrderBy    `json:"orders"`
	Limit        *Limit        `json:"limit"`
	Sql          string        `json:"sql"`
}

func (*Query) TranslateTimeIntervalToFilter

func (q *Query) TranslateTimeIntervalToFilter()

type Request

type Request struct {
	Metrics    []*Metric    `json:"metrics"`
	Dimensions []*Dimension `json:"dimensions"`
	Filters    []*Filter    `json:"filters"`
	Joins      []*Join      `json:"joins"`
	Orders     []*OrderBy   `json:"orders"`
	Limit      *Limit       `json:"limit"`
	DataSource *DataSource  `json:"data_source"`
	Sql        string       `json:"sql"`
}

func (*Request) Clause

func (r *Request) Clause(tx *gorm.DB) (*gorm.DB, error)

type Response

type Response struct {
	Rows []*Item `json:"rows"`
}

func ProtoToResponse

func ProtoToResponse(response *proto.Response) *Response

func (*Response) ToProto

func (r *Response) ToProto() *proto.Response

type Result

type Result struct {
	Dimensions []string                 `json:"dimensions"`
	Source     []map[string]interface{} `json:"source"`
}

func (*Result) AddSource

func (r *Result) AddSource(in map[string]interface{}) error

func (*Result) SetDimensions

func (r *Result) SetDimensions(query *Query)

type SingleCol

type SingleCol struct {
	Table string     `json:"table"`
	Name  string     `json:"name"`
	Alias string     `json:"alias"`
	Type  ColumnType `json:"type"`
}

func (*SingleCol) GetAlias

func (col *SingleCol) GetAlias() string

func (*SingleCol) GetExpression

func (col *SingleCol) GetExpression() string

type Statement

type Statement interface {
	Expression() (string, error) // Any expression
	Alias() (string, error)      // Name for expr. Aliases should comply with the identifiers syntax
	Statement() (string, error)  // expr AS alias
}

type TimeInterval

type TimeInterval struct {
	Name  string `json:"name"`
	Start string `json:"start"`
	End   string `json:"end"`
}

func (*TimeInterval) ToFilter

func (t *TimeInterval) ToFilter() *Filter

type ValueType

type ValueType string
const (
	ValueTypeUnknown ValueType = "VALUE_UNKNOWN"
	ValueTypeString  ValueType = "VALUE_STRING"
	ValueTypeInteger ValueType = "VALUE_INTEGER"
	ValueTypeFloat   ValueType = "VALUE_FLOAT"
)

func EnumToValueType

func EnumToValueType(v proto.VALUE_TYPE) ValueType

func (ValueType) ToEnum

func (v ValueType) ToEnum() proto.VALUE_TYPE

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL