types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 3 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 = "/"
	ArithmeticOperatorTypeAs       ArithmeticOperatorType = "as"
)

type Clause

type Clause interface {
	GetDBType() DBType
	GetDataset() string
	BuildDB(tx *gorm.DB) (*gorm.DB, error)
	BuildSQL(tx *gorm.DB) (string, error)
}

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"
	ColumnTypeAs            ColumnType = "as"
)

type DBType

type DBType = string
const (
	DBTypeSQLite     DBType = "sqlite"
	DBTypeMySQL      DBType = "mysql"
	DBTypePostgre    DBType = "postgres"
	DBTypeClickHouse DBType = "clickhouse"
)

type DataSource

type DataSource struct {
	Database  string         `json:"database"`
	Name      string         `json:"name"`
	AliasName string         `json:"alias"`
	Type      DataSourceType `json:"type"`
	Clause    Clause         `json:"clause"`
	// contains filtered or unexported fields
}

func (*DataSource) Alias

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

func (*DataSource) Expression

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

func (*DataSource) Init

func (d *DataSource) Init(tx *gorm.DB) (err error)

func (*DataSource) Statement

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

type DataSourceType

type DataSourceType string
const (
	DataSourceTypeFact              DataSourceType = "fact"
	DataSourceTypeDimension         DataSourceType = "dimension"
	DataSourceTypeFactDimensionJoin DataSourceType = "fact_dimension_join"
	DataSourceTypeMergeJoin         DataSourceType = "merge_join"
)

type Dimension

type Dimension struct {
	Table      string        `json:"table"`
	Name       string        `json:"name"`
	FieldName  string        `json:"field_name"`
	Type       DimensionType `json:"type"`
	ValueType  ValueType     `json:"value_type"`
	Dependency []*Dimension  `json:"dependency"`
}

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)

type DimensionType

type DimensionType string
const (
	DimensionTypeValue      DimensionType = "DIMENSION_VALUE"
	DimensionTypeSingle     DimensionType = "DIMENSION_SINGLE"
	DimensionTypeMulti      DimensionType = "DIMENSION_MULTI"
	DimensionTypeCase       DimensionType = "DIMENSION_CASE"
	DimensionTypeExpression DimensionType = "DIMENSION_EXPRESSION"
)

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 FieldProperty

type FieldProperty string
const (
	FieldPropertyDimension FieldProperty = "DIMENSION"
	FieldPropertyMetric    FieldProperty = "METRIC"
)

type Filter

type Filter struct {
	OperatorType  FilterOperatorType `toml:"operator_type"  json:"operator_type"`
	ValueType     ValueType          `toml:"value_type"     json:"value_type"`
	Table         string             `toml:"table"          json:"table"`
	Name          string             `toml:"name"           json:"name"`
	FieldProperty FieldProperty      `toml:"field_property" json:"field_property"`
	Value         []any              `toml:"value"          json:"value"`
	Children      []*Filter          `toml:"children"       json:"children"`
}

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)

type FilterOperatorType

type FilterOperatorType string
const (
	FilterOperatorTypeUnknown       FilterOperatorType = "FILTER_OPERATOR_UNKNOWN"
	FilterOperatorTypeEquals        FilterOperatorType = "FILTER_OPERATOR_EQUALS"
	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"
	FilterOperatorTypeHas           FilterOperatorType = "FILTER_OPERATOR_HAS"
	FilterOperatorTypeExpression    FilterOperatorType = "FILTER_OPERATOR_EXTENSION"
	FilterOperatorTypeAnd           FilterOperatorType = "FILTER_OPERATOR_AND"
	FilterOperatorTypeOr            FilterOperatorType = "FILTER_OPERATOR_OR"
)

func (FilterOperatorType) IsTree

func (f FilterOperatorType) IsTree() bool

type Join

type Join struct {
	DataSource1 *DataSource `json:"datasource1"`
	DataSource2 *DataSource `json:"datasource2"`
	JoinType    string      `json:"join_type"`
	On          []*JoinOn   `json:"on"`
	Filters     []*Filter   `json:"filters"`
}

func (*Join) GetJoinType

func (j *Join) GetJoinType() string

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"`
}

type Metric

type Metric struct {
	Table     string     `json:"table"`
	Name      string     `json:"name"`
	Type      MetricType `json:"type"`
	FieldName string     `json:"field_name"`
	ValueType ValueType  `json:"value_type"`
	Children  []*Metric  `json:"children"`
	Filter    *Filter    `json:"filter"`
	DBType    DBType     `json:"db_type"`
}

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)

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: 相除指标
	MetricTypeAs            MetricType = "METRIC_AS"             // composition type eg: 关联指标
	MetricTypeExpression    MetricType = "METRIC_EXPRESSION"     // single type. eg: 表达式

)

type NormalClause

type NormalClause 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"`
	// contains filtered or unexported fields
}

func (*NormalClause) BuildDB

func (n *NormalClause) BuildDB(tx *gorm.DB) (*gorm.DB, error)

func (*NormalClause) BuildSQL

func (n *NormalClause) BuildSQL(tx *gorm.DB) (string, error)

func (*NormalClause) GetDBType

func (b *NormalClause) GetDBType() DBType

func (*NormalClause) GetDataset

func (b *NormalClause) GetDataset() string

type OrderBy

type OrderBy struct {
	Table         string             `json:"table"`
	Name          string             `json:"name"`
	FieldProperty FieldProperty      `json:"field_property"`
	Direction     OrderDirectionType `json:"direction"`
}

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)

type OrderDirectionType

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

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 Result

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

func (*Result) AddSource

func (r *Result) AddSource(in map[string]any) error

func (*Result) SetDimensions

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

type SingleCol

type SingleCol struct {
	DBType DBType     `json:"db_type"`
	Table  string     `json:"table"`
	Name   string     `json:"name"`
	Alias  string     `json:"alias"`
	Type   ColumnType `json:"type"`
	Filter *Filter    `json:"filter"`
}

func (*SingleCol) GetAlias

func (col *SingleCol) GetAlias() string

func (*SingleCol) GetExpression

func (col *SingleCol) GetExpression() string

func (*SingleCol) GetIfExpression

func (col *SingleCol) GetIfExpression() (string, error)

type SqlClause

type SqlClause struct {
	Sql string
	// contains filtered or unexported fields
}

func (*SqlClause) BuildDB

func (s *SqlClause) BuildDB(tx *gorm.DB) (*gorm.DB, error)

func (*SqlClause) BuildSQL

func (s *SqlClause) BuildSQL(*gorm.DB) (string, error)

func (*SqlClause) GetDBType

func (b *SqlClause) GetDBType() DBType

func (*SqlClause) GetDataset

func (b *SqlClause) GetDataset() 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"
)

Jump to

Keyboard shortcuts

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