qlutils

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 6 Imported by: 13

Documentation

Overview

Package qlutils contains utilities for handling influx ql queries.

Index

Constants

This section is empty.

Variables

View Source
var (
	// means the query contains a statement that is not a select statement.
	ErrNonSelectStatement = errors.New("qlutils: Non select statement")
	ErrUnsupported        = errors.New("qlutils: Unsupported")
)

Functions

func AggregationType

func AggregationType(stmt influxql.Statement) (lowercase string, err error)

AggregationType returns that aggregation function stmt uses in lowercase. AggregationType returns an error if stmt doesn't use an aggregation function.

func NewQuery

func NewQuery(ql string, currentTime time.Time) (*influxql.Query, error)

NewQuery creates a new query instance from a string substituting currentTime for now().

func ParseQuery

func ParseQuery(query *influxql.Query, now time.Time) (
	parsedQueries []tsdbjson.ParsedQuery,
	columnNameSets [][]string,
	err error)

ParsedQuery converts a query to tsdb ParsedQuery instances for scotty. ParsedQuery creates one ParsedQuery instance for each select statement in the passed query. ParseQuery also returns the column names for each result set. The number of column name sets returned always equals the number of ParseQuery instances returned.

func QuerySetTimeRange

func QuerySetTimeRange(
	query *influxql.Query, min, max time.Time) (*influxql.Query, error)

QuerySetTimeRange returns a query just like query except that it is only for times falling between min inclusive and max exclusive. If none of the select statements in the query matches the given time range, returns nil, nil

func QueryTimeRange

func QueryTimeRange(
	query *influxql.Query, now time.Time) (min, max time.Time, err error)

QueryTimeRange returns the min and max time for a query. If no min time found, min is the zero value; if no max time found, max = now.

func SingleQuery

func SingleQuery(stmt influxql.Statement) *influxql.Query

SingleQuery turns a statement into a query with that one statement.

func WithAggregationType

func WithAggregationType(stmt influxql.Statement, aggregation string) (
	influxql.Statement, error)

WithAggregationType returns a statement like stmt that uses aggregation as the aggregation function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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