Documentation
¶
Overview ¶
Package dql wraps DQL query SDK.
Index ¶
- func BuildDQL(dqlStr string, opts ...DQLOption) (*dql, error)
- func MustBuildDQL(dql string, opts ...DQLOption) *dql
- type AsyncSearchTaskPayload
- type Client
- type DQLOption
- func WithAlignTime(on bool) DQLOption
- func WithAsync(on bool) DQLOption
- func WithAsyncID(id string) DQLOption
- func WithAsyncTimeout(du time.Duration) DQLOption
- func WithConditions(conditions string) DQLOption
- func WithCursorTime(n int64) DQLOption
- func WithDisableExpensiveQuery(on bool) DQLOptiondeprecated
- func WithDisableMultipleField(on bool) DQLOption
- func WithDisableQueryParse(on bool) DQLOption
- func WithDisableSLimit(on bool) DQLOption
- func WithHighlight(on bool) DQLOption
- func WithLargeQuery(on bool) DQLOption
- func WithLimit(n int64) DQLOption
- func WithMaskVisible(on bool) DQLOption
- func WithMaxDuration(du time.Duration) DQLOption
- func WithMaxPoint(n int) DQLOption
- func WithMultipleWorkspaceRules(rules ...*WorkspaceIndexRule) DQLOption
- func WithOffset(n int) DQLOption
- func WithOptimized(on bool) DQLOption
- func WithOrderBy(k string, order OrderByOrder) DQLOption
- func WithOutputFormat(of OutputFormat) DQLOption
- func WithProfile(on bool) DQLOption
- func WithQueryType(t string) DQLOption
- func WithRoleRules(rules map[string][]QueryRule) DQLOption
- func WithSLimit(n int) DQLOption
- func WithSOffset(n int) DQLOption
- func WithSOrderBy(k string, order OrderByOrder) DQLOption
- func WithSampling(on bool) DQLOption
- func WithSearchAfter(after ...any) DQLOption
- func WithShowLabel(on bool) DQLOptiondeprecated
- func WithStepInterval(n int64) DQLOption
- func WithTimeRange(start, end int) DQLOption
- func WithTimeout(du time.Duration) DQLOption
- type DQLResult
- type DorisIndices
- type OrderByOrder
- type OutputFormat
- type QueryOption
- type QueryRule
- type Result
- type Row
- type WorkspaceIndexRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDQL ¶
BuildDQL used to build a DQL query with one or more options. dqlStr is the basic DQL query string.
func MustBuildDQL ¶
MustBuildDQL build a DQL query, and panic on any error. Most of the time, the build will not fail, we can use the Must function without worry.
Types ¶
type AsyncSearchTaskPayload ¶ added in v0.1.1
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is the DQL query client connecting to a exist Datakit or directly to Dataway(and the token required).
type DQLOption ¶
type DQLOption func(*dql)
DQLOption used to set various DQL options.
func WithAlignTime ¶ added in v0.1.2
WithAlignTime enable time alignment for query result.
func WithAsyncID ¶ added in v0.1.1
WithAsyncID fetch async query result on the id.
func WithAsyncTimeout ¶
WithAsyncTimeout set async query timeout.
func WithConditions ¶
WithConditions set extra where-condtions to DQL.
func WithCursorTime ¶ added in v0.1.2
WithCursorTime set cursort timestamp for paging. The timestamp n can be s/ms/us, and the backend will guess the unit of the timestamp.
func WithDisableExpensiveQuery
deprecated
WithDisableExpensiveQuery disable/enable expensive query. For left wildcard like following will trigger a expensive query.
L::some_source { f1 = wildcard('*xx') }
NOTE: Disable all expensive query are a good manner to protect your worksapce.
Deprecated: Option removed for DQL.
func WithDisableMultipleField ¶
WithDisableMultipleField disable/enable query multiple field in single DQL.
func WithDisableQueryParse ¶
WithDisableQueryParse disable/enable query parse.
func WithDisableSLimit ¶
WithDisableSLimit disable/enable default slimit.
func WithHighlight ¶
WithHighlight enable/disable highlight on query result.
func WithLargeQuery ¶ added in v0.1.2
WithLargeQuery enable/disable large-data-set query. Large-data-set query default enabled, but we can disable it to protect backend storage.
func WithMaskVisible ¶
WithMaskVisible set visible/hide on sensitive fields.
func WithMaxDuration ¶
WithMaxDuration set DQL max time range, this option used to avoid unexpected too-large query. If time range in DQL exceed max duration, there will be a query error returned. For example, following DQL will fail if max duration set to 1 hour:
L::some_source [1d:] # query latest 24h logging
We will get a error like:
parse error: time range should less than 1h0m0s
func WithMaxPoint ¶
WithMaxPoint used to control max query points under group by, for example:
L::re(`.*`):(fill(count(__docid), 0) AS count) [1d] BY status
All logs are group by its status, each status(bucket) may have different number of logs, and we can limit only n points in each status.
func WithMultipleWorkspaceRules ¶ added in v0.1.2
func WithMultipleWorkspaceRules(rules ...*WorkspaceIndexRule) DQLOption
WithMultipleWorkspaceRules query among multiple workspaces.
Workspace rules example:
rules := []*WorkspaceIndexRule{ &WorkspaceIndexRule{ WorkspaceUUID: "wksp_4b57c7bab38e4a2d9630xxxxxxxxxxxx", IndexName: "default", Rules: any{}, // See rules in WithRoleRules }, }
func WithOptimized ¶ added in v0.1.1
WithOptimized enable optimize on query. For example, if query 7 days data, the query will only response the first index data. If order by ASC, the first index is the oldest index.
NOTE: not available on M::.
func WithOrderBy ¶
func WithOrderBy(k string, order OrderByOrder) DQLOption
WithOrderBy used to set order-by on point.
func WithOutputFormat ¶
func WithOutputFormat(of OutputFormat) DQLOption
WithOutputFormat set output format, currently only support LineProtocol.
func WithProfile ¶ added in v0.1.1
WithProfile enable profiling. Only available for OpenSearch backend.
func WithQueryType ¶ added in v0.1.2
WithQueryType set query type, only "dql" or "promql" are allowed.
func WithRoleRules ¶ added in v0.1.2
WithRoleRules set role rules for the query.
Rules example:
rules := map[string][]QueryRule{ "logging": []QueryRule{ // rule for query logging(aka L::) data. QueryRule{ Rule: `fruit IN ['apple', 'orange']`, Index: []string{"my-logging-index-name"}, }, }, }
func WithSOrderBy ¶ added in v0.1.2
func WithSOrderBy(k string, order OrderByOrder) DQLOption
WithSOrderBy used to set order-by on series.
func WithSampling ¶ added in v0.1.2
WithSampling used to enable/disable sampling of the query result.
func WithSearchAfter ¶
WithSearchAfter used to set search-after of the DQL query.
func WithShowLabel
deprecated
func WithStepInterval ¶ added in v0.1.2
WithStepInterval set time step interval for time-aggregate query.
func WithTimeRange ¶
WithTimeRange used to set time range of the DQL query. start and end are UNIX timestamp in ms.
func WithTimeout ¶ added in v0.1.1
WithTimeout set query timeout.
type DQLResult ¶
type DQLResult struct { Series []*Row `json:"series"` // Base64 encoded lineprotocol output Points []string `json:"points"` GroupByList []string `json:"group_by,omitempty"` SearchAfter []interface{} `json:"search_after,omitempty"` Cost string `json:"cost"` RawQuery string `json:"raw_query,omitempty"` QueryParse interface{} `json:"query_parse,omitempty"` QueryWarning string `json:"query_warning,omitempty"` Totalhits int64 `json:"total_hits,omitempty"` FilterCount int64 `json:"filter_count,omitempty"` // Async query ID AsyncID string `json:"async_id,omitempty"` // Logging index name IndexName string `json:"index_name"` // Logging storage type(sls/outer_sls/es) IndexStoreType string `json:"index_store_type"` // Query type(influxdb/tdengine/guancedb) QueryType string `json:"query_type"` // Async query still running or not IsRunning bool `json:"is_running"` Complete bool `json:"complete"` IndexNames string `json:"index_names"` // index names }
A DQLResult is a single DQL's query result.
type DorisIndices ¶ added in v0.1.2
type OrderByOrder ¶
type OrderByOrder int
A OrderByOrder is the order-by option, DESC or ASC.
const ( ASC OrderByOrder = iota DESC )
The order-by options: asc and desc.
func (OrderByOrder) String ¶
func (o OrderByOrder) String() string
String is the string-representation of DESC and ASC.
type OutputFormat ¶
type OutputFormat int
A OutputFormat is the query result format.
const (
LineProtocol OutputFormat = iota
)
Query result formats.
func (OutputFormat) String ¶
func (of OutputFormat) String() string
String used to get the output format in string representation.
type QueryOption ¶
type QueryOption func(*query)
QueryOption used to set various query options.
func WithEchoExplain ¶
func WithEchoExplain(on bool) QueryOption
WithEchoExplain used to echo the translated query of the DQL.
func WithHTTPS ¶ added in v0.1.1
func WithHTTPS(on bool) QueryOption
WithHTTPS are required if we want to send the query to public openway.
func WithQueries ¶
func WithQueries(arr ...*dql) QueryOption
WithQueries used to send one or more DQLs to a query request.
func WithToken ¶ added in v0.1.1
func WithToken(token string) QueryOption
WithToken enable we send the query to Dataway directly.
type Result ¶
type Result struct { ErrorCode string `json:"error_code,omitempty"` Message string `json:"message,omitempty"` Content []*DQLResult `json:"content"` }
A Result is the query result of DQL request. Within a Result there maybe multiple DQL query result. If there any error on query, we can see them with ErrorCode and Message.
type Row ¶
type Row struct { Name string `json:"name,omitempty"` Tags map[string]string `json:"tags,omitempty"` Columns []string `json:"columns,omitempty"` Values [][]interface{} `json:"values,omitempty"` Partial bool `json:"partial,omitempty"` }
Row represents a single row returned from the execution of a statement.