query

package
v0.0.4-0...-a9841f4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ascending  Order = "ASCENDING"
	Descending       = "DESCENDING"
	None             = "NONE"
)
View Source
const (
	Cardinality      AnalysisType = "CARDINALITY"
	Size                          = "SIZE"
	Interval                      = "INTERVAL"
	Aggregators                   = "AGGREGATORS"
	MinMax                        = "MINMAX"
	TimestampSpec                 = "TIMESTAMPSPEC"
	QueryGranularity              = "QUERYGRANULARITY"
	Rollup                        = "ROLLUP"
)

Variables

This section is empty.

Functions

func Load

func Load(data []byte) (builder.Query, error)

Types

type AnalysisType

type AnalysisType string

type Base

type Base struct {
	ID         string                 `json:"ID,omitempty"`
	QueryType  builder.ComponentType  `json:"queryType,omitempty"`
	DataSource builder.DataSource     `json:"dataSource,omitempty"`
	Intervals  builder.Intervals      `json:"intervals,omitempty"`
	Context    map[string]interface{} `json:"context,omitempty"`
}

func (*Base) SetContext

func (b *Base) SetContext(context map[string]interface{}) *Base

func (*Base) SetDataSource

func (b *Base) SetDataSource(dataSource builder.DataSource) *Base

func (*Base) SetID

func (b *Base) SetID(ID string) *Base

func (*Base) SetIntervals

func (b *Base) SetIntervals(intervals builder.Intervals) *Base

func (*Base) SetQueryType

func (b *Base) SetQueryType(queryType builder.ComponentType) *Base

func (*Base) Type

func (b *Base) Type() builder.ComponentType

func (*Base) UnmarshalJSON

func (b *Base) UnmarshalJSON(data []byte) error

type DataSourceMetadata

type DataSourceMetadata struct {
	Base
}

func NewDataSourceMetadata

func NewDataSourceMetadata() *DataSourceMetadata

func (*DataSourceMetadata) SetContext

func (d *DataSourceMetadata) SetContext(context map[string]interface{}) *DataSourceMetadata

func (*DataSourceMetadata) SetDataSource

func (d *DataSourceMetadata) SetDataSource(dataSource builder.DataSource) *DataSourceMetadata

func (*DataSourceMetadata) SetIntervals

func (d *DataSourceMetadata) SetIntervals(intervals builder.Intervals) *DataSourceMetadata

type GroupBy

type GroupBy struct {
	Base
	Dimensions       []builder.Dimension      `json:"dimensions,omitempty"`
	VirtualColumns   []builder.VirtualColumn  `json:"virtualColumns,omitempty"`
	Filter           builder.Filter           `json:"filter,omitempty"`
	Granularity      builder.Granularity      `json:"granularity,omitempty"`
	Aggregations     []builder.Aggregator     `json:"aggregations,omitempty"`
	PostAggregations []builder.PostAggregator `json:"postAggregations,omitempty"`
	Having           builder.HavingSpec       `json:"having,omitempty"`
	LimitSpec        builder.LimitSpec        `json:"limitSpec,omitempty"`
	SubtotalsSpec    [][]string               `json:"subtotalsSpec,omitempty"`
}

func NewGroupBy

func NewGroupBy() *GroupBy

func (*GroupBy) SetAggregations

func (g *GroupBy) SetAggregations(aggregations []builder.Aggregator) *GroupBy

func (*GroupBy) SetContext

func (g *GroupBy) SetContext(context map[string]interface{}) *GroupBy

func (*GroupBy) SetDataSource

func (g *GroupBy) SetDataSource(dataSource builder.DataSource) *GroupBy

func (*GroupBy) SetDimensions

func (g *GroupBy) SetDimensions(dimensions []builder.Dimension) *GroupBy

func (*GroupBy) SetFilter

func (g *GroupBy) SetFilter(filter builder.Filter) *GroupBy

func (*GroupBy) SetGranularity

func (g *GroupBy) SetGranularity(granularity builder.Granularity) *GroupBy

func (*GroupBy) SetHaving

func (g *GroupBy) SetHaving(having builder.HavingSpec) *GroupBy

func (*GroupBy) SetIntervals

func (g *GroupBy) SetIntervals(intervals builder.Intervals) *GroupBy

func (*GroupBy) SetLimitSpec

func (g *GroupBy) SetLimitSpec(limitSpec builder.LimitSpec) *GroupBy

func (*GroupBy) SetPostAggregations

func (g *GroupBy) SetPostAggregations(postAggregations []builder.PostAggregator) *GroupBy

func (*GroupBy) SetSubtotalsSpec

func (g *GroupBy) SetSubtotalsSpec(subtotalsSpec [][]string) *GroupBy

func (*GroupBy) SetVirtualColumns

func (g *GroupBy) SetVirtualColumns(virtualColumns []builder.VirtualColumn) *GroupBy

func (*GroupBy) UnmarshalJSON

func (g *GroupBy) UnmarshalJSON(data []byte) error

type Order

type Order string

type SQL

type SQL struct {
	Base
	Query        string         `json:"query,omitempty"`
	ResultFormat string         `json:"resultFormat,omitempty"`
	Header       bool           `json:"header,omitempty"`
	Parameters   []SQLParameter `json:"parameters,omitempty"`
}

func NewSQL

func NewSQL() *SQL

func (*SQL) SetHeader

func (s *SQL) SetHeader(header bool) *SQL

func (*SQL) SetParameters

func (s *SQL) SetParameters(parameters []SQLParameter) *SQL

func (*SQL) SetQuery

func (s *SQL) SetQuery(query string) *SQL

func (*SQL) SetResultFormat

func (s *SQL) SetResultFormat(resultFormat string) *SQL

func (*SQL) UnmarshalJSON

func (s *SQL) UnmarshalJSON(data []byte) error

type SQLParameter

type SQLParameter struct {
	Type  string `json:"type,omitempty"`
	Value string `json:"value,omitempty"`
}

func NewSQLParameter

func NewSQLParameter() *SQLParameter

type Scan

type Scan struct {
	Base
	VirtualColumns []builder.VirtualColumn `json:"virtualColumns,omitempty"`
	ResultFormat   string                  `json:"resultFormat,omitempty"`
	BatchSize      int64                   `json:"batchSize,omitempty"`
	Limit          int64                   `json:"limit,omitempty"`
	Offset         int64                   `json:"offset,omitempty"`
	Order          Order                   `json:"order,omitempty"`
	Filter         builder.Filter          `json:"filter,omitempty"`
	Columns        []string                `json:"columns,omitempty"`
	Legacy         bool                    `json:"legacy,omitempty"`
}

Scan query returns raw Apache Druid rows in streaming mode. https://druid.apache.org/docs/latest/querying/scan-query.html

func NewScan

func NewScan() *Scan

NewScan returns *builder.Scan which can be used to build a scan query. Eg,

table := datasource.NewTable().SetName("table-name")

now := time.Now()
i := intervals.NewInterval().SetInterval(now.Add(-60*time.Minute), now)
is := intervals.NewIntervals().SetIntervals([]*intervals.Interval{i})

filter1 := filter.NewSelector().SetDimension("key1").SetValue("val1")
filter2 := filter.NewSelector().SetDimension("key2").SetValue("val2")
filters := filter.NewAnd().SetFields([]builder.Filter{filter1, filter2})

ts := query.NewScan().SetDataSource(table).SetIntervals(is).SetFilter(filters).SetResultFormat("compactedList").SetLimit(10)

func (*Scan) SetBatchSize

func (s *Scan) SetBatchSize(batchSize int64) *Scan

SetBatchSize sets the batch size.

func (*Scan) SetColumns

func (s *Scan) SetColumns(columns []string) *Scan

SetColumns set columns.

func (*Scan) SetContext

func (s *Scan) SetContext(context map[string]interface{}) *Scan

SetContext sets the context.

func (*Scan) SetDataSource

func (s *Scan) SetDataSource(dataSource builder.DataSource) *Scan

SetDataSource sets data source.

func (*Scan) SetFilter

func (s *Scan) SetFilter(filter builder.Filter) *Scan

SetFilter sets the filter.

func (*Scan) SetIntervals

func (s *Scan) SetIntervals(intervals builder.Intervals) *Scan

SetIntervals set the intervals.

func (*Scan) SetLegacy

func (s *Scan) SetLegacy(legacy bool) *Scan

SetLegacy sets the `druid.query.scan.legacy` field.

func (*Scan) SetLimit

func (s *Scan) SetLimit(limit int64) *Scan

SetLimit sets the limit.

func (*Scan) SetOffset

func (s *Scan) SetOffset(offset int64) *Scan

SetOffset sets the offset.

func (*Scan) SetOrder

func (s *Scan) SetOrder(order Order) *Scan

SetOrder sets the order.

func (*Scan) SetResultFormat

func (s *Scan) SetResultFormat(resultFormat string) *Scan

SetResultFormat sets the result format.

func (*Scan) SetVirtualColumns

func (s *Scan) SetVirtualColumns(virtualColumns []builder.VirtualColumn) *Scan

SetVirtualColumns sets virtual columns.

func (*Scan) UnmarshalJSON

func (s *Scan) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls a druid scan native query json string into builder type.

type Search struct {
	Base
	Filter           builder.Filter          `json:"filter,omitempty"`
	Granularity      builder.Granularity     `json:"granularity,omitempty"`
	Limit            int64                   `json:"limit,omitempty"`
	SearchDimensions []builder.Dimension     `json:"searchDimensions,omitempty"`
	Query            builder.SearchQuerySpec `json:"query,omitempty"`
	Sort             *SearchSortSpec         `json:"sort,omitempty"`
}

func NewSearch

func NewSearch() *Search

func (*Search) SetContext

func (s *Search) SetContext(context map[string]interface{}) *Search

func (*Search) SetDataSource

func (s *Search) SetDataSource(dataSource builder.DataSource) *Search

func (*Search) SetFilter

func (s *Search) SetFilter(filter builder.Filter) *Search

func (*Search) SetGranularity

func (s *Search) SetGranularity(granularity builder.Granularity) *Search

func (*Search) SetIntervals

func (s *Search) SetIntervals(intervals builder.Intervals) *Search

func (*Search) SetLimit

func (s *Search) SetLimit(limit int64) *Search

func (*Search) SetQuery

func (s *Search) SetQuery(q builder.SearchQuerySpec) *Search

func (*Search) SetSearchDimensions

func (s *Search) SetSearchDimensions(searchDimensions []builder.Dimension) *Search

func (*Search) SetSort

func (s *Search) SetSort(sort *SearchSortSpec) *Search

func (*Search) UnmarshalJSON

func (s *Search) UnmarshalJSON(data []byte) error

type SearchSortSpec

type SearchSortSpec struct {
	Type types.StringComparator `json:"type,omitempty"`
}

type SegmentMetadata

type SegmentMetadata struct {
	Base
	ToInclude              builder.ToInclude `json:"toInclude,omitempty"`
	Merge                  bool              `json:"merge,omitempty"`
	AnalysisTypes          []AnalysisType    `json:"analysisTypes,omitempty"`
	UsingDefaultInterval   bool              `json:"usingDefaultInterval,omitempty"`
	LenientAggregatorMerge bool              `json:"lenientAggregatorMerge,omitempty"`
}

func NewSegmentMetadata

func NewSegmentMetadata() *SegmentMetadata

func (*SegmentMetadata) SetAnalysisTypes

func (s *SegmentMetadata) SetAnalysisTypes(analysisTypes []AnalysisType) *SegmentMetadata

func (*SegmentMetadata) SetContext

func (s *SegmentMetadata) SetContext(context map[string]interface{}) *SegmentMetadata

func (*SegmentMetadata) SetDataSource

func (s *SegmentMetadata) SetDataSource(dataSource builder.DataSource) *SegmentMetadata

func (*SegmentMetadata) SetIntervals

func (s *SegmentMetadata) SetIntervals(intervals builder.Intervals) *SegmentMetadata

func (*SegmentMetadata) SetLenientAggregatorMerge

func (s *SegmentMetadata) SetLenientAggregatorMerge(lenientAggregatorMerge bool) *SegmentMetadata

func (*SegmentMetadata) SetMerge

func (s *SegmentMetadata) SetMerge(merge bool) *SegmentMetadata

func (*SegmentMetadata) SetToInclude

func (s *SegmentMetadata) SetToInclude(toInclude builder.ToInclude) *SegmentMetadata

func (*SegmentMetadata) SetUsingDefaultInterval

func (s *SegmentMetadata) SetUsingDefaultInterval(usingDefaultInterval bool) *SegmentMetadata

func (*SegmentMetadata) UnmarshalJSON

func (s *SegmentMetadata) UnmarshalJSON(data []byte) error

type TimeBoundary

type TimeBoundary struct {
	Base
	Bound  string         `json:"bound,omitempty"`
	Filter builder.Filter `json:"filter,omitempty"`
}

func NewTimeBoundary

func NewTimeBoundary() *TimeBoundary

func (*TimeBoundary) SetBound

func (t *TimeBoundary) SetBound(bound string) *TimeBoundary

func (*TimeBoundary) SetContext

func (t *TimeBoundary) SetContext(context map[string]interface{}) *TimeBoundary

func (*TimeBoundary) SetDataSource

func (t *TimeBoundary) SetDataSource(dataSource builder.DataSource) *TimeBoundary

func (*TimeBoundary) SetFilter

func (t *TimeBoundary) SetFilter(filter builder.Filter) *TimeBoundary

func (*TimeBoundary) SetIntervals

func (t *TimeBoundary) SetIntervals(intervals builder.Intervals) *TimeBoundary

func (*TimeBoundary) UnmarshalJSON

func (t *TimeBoundary) UnmarshalJSON(data []byte) error

type Timeseries

type Timeseries struct {
	Base
	Descending       bool                     `json:"descending,omitempty"`
	VirtualColumns   []builder.VirtualColumn  `json:"virtualColumns,omitempty"`
	Filter           builder.Filter           `json:"filter,omitempty"`
	Granularity      builder.Granularity      `json:"granularity,omitempty"`
	Aggregations     []builder.Aggregator     `json:"aggregations,omitempty"`
	PostAggregations []builder.PostAggregator `json:"postAggregations,omitempty"`
	Limit            int64                    `json:"limit,omitempty"`
}

func NewTimeseries

func NewTimeseries() *Timeseries

func (*Timeseries) SetAggregations

func (t *Timeseries) SetAggregations(aggregations []builder.Aggregator) *Timeseries

func (*Timeseries) SetContext

func (t *Timeseries) SetContext(context map[string]interface{}) *Timeseries

func (*Timeseries) SetDataSource

func (t *Timeseries) SetDataSource(dataSource builder.DataSource) *Timeseries

func (*Timeseries) SetDescending

func (t *Timeseries) SetDescending(descending bool) *Timeseries

func (*Timeseries) SetFilter

func (t *Timeseries) SetFilter(filter builder.Filter) *Timeseries

func (*Timeseries) SetGranularity

func (t *Timeseries) SetGranularity(granularity builder.Granularity) *Timeseries

func (*Timeseries) SetIntervals

func (t *Timeseries) SetIntervals(intervals builder.Intervals) *Timeseries

func (*Timeseries) SetLimit

func (t *Timeseries) SetLimit(limit int64) *Timeseries

func (*Timeseries) SetPostAggregations

func (t *Timeseries) SetPostAggregations(postAggregations []builder.PostAggregator) *Timeseries

func (*Timeseries) SetVirtualColumns

func (t *Timeseries) SetVirtualColumns(virtualColumns []builder.VirtualColumn) *Timeseries

func (*Timeseries) UnmarshalJSON

func (t *Timeseries) UnmarshalJSON(data []byte) error

type TopN

type TopN struct {
	Base
	VirtualColumns   []builder.VirtualColumn  `json:"virtualColumns,omitempty"`
	Dimension        builder.Dimension        `json:"dimension,omitempty"`
	Metric           builder.TopNMetric       `json:"metric,omitempty"`
	Threshold        int64                    `json:"threshold,omitempty"`
	Filter           builder.Filter           `json:"filter,omitempty"`
	Granularity      builder.Granularity      `json:"granularity,omitempty"`
	Aggregations     []builder.Aggregator     `json:"aggregations,omitempty"`
	PostAggregations []builder.PostAggregator `json:"postAggregations,omitempty"`
}

func NewTopN

func NewTopN() *TopN

func (*TopN) SetAggregations

func (t *TopN) SetAggregations(aggregations []builder.Aggregator) *TopN

func (*TopN) SetContext

func (t *TopN) SetContext(context map[string]interface{}) *TopN

func (*TopN) SetDataSource

func (t *TopN) SetDataSource(dataSource builder.DataSource) *TopN

func (*TopN) SetDimension

func (t *TopN) SetDimension(dimension builder.Dimension) *TopN

func (*TopN) SetFilter

func (t *TopN) SetFilter(filter builder.Filter) *TopN

func (*TopN) SetGranularity

func (t *TopN) SetGranularity(granularity builder.Granularity) *TopN

func (*TopN) SetIntervals

func (t *TopN) SetIntervals(intervals builder.Intervals) *TopN

func (*TopN) SetMetric

func (t *TopN) SetMetric(metric builder.TopNMetric) *TopN

func (*TopN) SetPostAggregations

func (t *TopN) SetPostAggregations(postAggregations []builder.PostAggregator) *TopN

func (*TopN) SetThreshold

func (t *TopN) SetThreshold(threshold int64) *TopN

func (*TopN) SetVirtualColumns

func (t *TopN) SetVirtualColumns(virtualColumns []builder.VirtualColumn) *TopN

func (*TopN) UnmarshalJSON

func (t *TopN) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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