Documentation
¶
Overview ¶
Package influxql implements the transpiler for executing influxql queries in the 2.0 query engine.
Index ¶
- Constants
- func AddCompilerMappings(mappings flux.CompilerMappings, dbrpMappingSvc platform.DBRPMappingServiceV2) error
- func AddDialectMappings(mappings flux.DialectMappings) error
- func Join(t *transpilerState, cursors []cursor, on []string) cursor
- func NewResponseIterator(r *Response) flux.ResultIterator
- type Compiler
- type CompressionFormat
- type Config
- type Dialect
- type EncodingFormat
- type Endpoint
- type Message
- type MultiResultEncoder
- type Response
- type Result
- type Row
- type Service
- type TimeFormat
- type Transpiler
Constants ¶
const CompilerType = "influxql"
const DialectType = "influxql"
Variables ¶
This section is empty.
Functions ¶
func AddCompilerMappings ¶
func AddCompilerMappings(mappings flux.CompilerMappings, dbrpMappingSvc platform.DBRPMappingServiceV2) error
AddCompilerMappings adds the influxql specific compiler mappings.
func AddDialectMappings ¶
func AddDialectMappings(mappings flux.DialectMappings) error
AddDialectMappings adds the influxql specific dialect mappings.
func NewResponseIterator ¶
func NewResponseIterator(r *Response) flux.ResultIterator
NewResponseIterator constructs a flux.ResultIterator from a Response.
Types ¶
type Compiler ¶
type Compiler struct {
Cluster string `json:"cluster,omitempty"`
DB string `json:"db,omitempty"`
RP string `json:"rp,omitempty"`
Bucket string `json:"bucket,omitempty"`
Query string `json:"query"`
Now *time.Time `json:"now,omitempty"`
// contains filtered or unexported fields
}
Compiler is the transpiler to convert InfluxQL to a Flux specification.
func NewCompiler ¶
func NewCompiler(dbrpMappingSvc platform.DBRPMappingServiceV2) *Compiler
func (*Compiler) CompilerType ¶
func (c *Compiler) CompilerType() flux.CompilerType
func (*Compiler) WithLogicalPlannerOptions ¶
func (c *Compiler) WithLogicalPlannerOptions(opts ...plan.LogicalOption)
type CompressionFormat ¶
type CompressionFormat int
CompressionFormat is the format to compress the query results.
const ( // None does not compress the results and is the default. None CompressionFormat = iota // Gzip compresses the query results with gzip. Gzip )
type Config ¶
type Config struct {
// Bucket is the name of a bucket to use instead of the db/rp from the query.
// If bucket is empty then the dbrp mapping is used.
Bucket string
DefaultDatabase string
DefaultRetentionPolicy string
Cluster string
Now time.Time
// FallbackToDBRP if true will use the naming convention of `db/rp`
// for a bucket name when an mapping is not found
FallbackToDBRP bool
}
Config modifies the behavior of the Transpiler.
type Dialect ¶
type Dialect struct {
TimeFormat TimeFormat // TimeFormat is the format of the timestamp; defaults to RFC3339Nano.
Encoding EncodingFormat // Encoding is the format of the results; defaults to JSON.
ChunkSize int // Chunks is the number of points per chunk encoding batch; defaults to 0 or no chunking.
Compression CompressionFormat // Compression is the compression of the result output; defaults to None.
}
Dialect describes the output format of InfluxQL queries.
func (*Dialect) DialectType ¶
func (d *Dialect) DialectType() flux.DialectType
func (*Dialect) Encoder ¶
func (d *Dialect) Encoder() flux.MultiResultEncoder
func (*Dialect) SetHeaders ¶
func (d *Dialect) SetHeaders(w http.ResponseWriter)
type EncodingFormat ¶
type EncodingFormat int
EncodingFormat is the output format for the query response content.
const ( // JSON marshals the response to JSON octets. JSON EncodingFormat = iota // JSONPretty marshals the response to JSON octets with indents. JSONPretty // CSV marshals the response to CSV. CSV // Msgpack has a similar structure as the JSON response. Used? Msgpack )
type Endpoint ¶
type Endpoint struct {
URL string `json:"url"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
Endpoint contains the necessary information to connect to a specific cluster.
type MultiResultEncoder ¶
type MultiResultEncoder struct{}
MultiResultEncoder encodes results as InfluxQL JSON format.
func NewMultiResultEncoder ¶
func NewMultiResultEncoder() *MultiResultEncoder
func (*MultiResultEncoder) Encode ¶
func (e *MultiResultEncoder) Encode(w io.Writer, results flux.ResultIterator) (int64, error)
Encode writes a collection of results to the influxdb 1.X http response format. Expectations/Assumptions:
- Each result will be published as a 'statement' in the top-level list of results. The result name will be interpreted as an integer and used as the statement id.
- If the _measurement name is present in the group key, it will be used as the result name instead of as a normal tag.
- All columns in the group key must be strings and they will be used as tags. There is no current way to have a tag and field be the same name in the results. TODO(jsternberg): For full compatibility, the above must be possible.
- All other columns are fields and will be output in the order they are found. TODO(jsternberg): This function currently requires the first column to be a time field, but this isn't a strict requirement and will be lifted when we begin to work on transpiling meta queries.
type Result ¶
type Result struct {
// StatementID is just the statement's position in the query. It's used
// to combine statement results if they're being buffered in memory.
StatementID int `json:"statement_id"`
Series []*Row `json:"series,omitempty"`
Messages []*Message `json:"messages,omitempty"`
Partial bool `json:"partial,omitempty"`
Err string `json:"error,omitempty"`
}
Result represents a resultset returned from a single statement. Rows represents a list of rows that can be sorted consistently by name/tag.
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.
type Service ¶
type Service struct {
// Endpoints maps a cluster name to the influxdb 1.x endpoint.
Endpoints map[string]Endpoint
}
Service is a client for the influxdb 1.x endpoint that implements the QueryService for the influxql compiler type.
type TimeFormat ¶
type TimeFormat int
TimeFormat specifies the format of the timestamp in the query results.
const ( // RFC3339Nano is the default format for timestamps for InfluxQL. RFC3339Nano TimeFormat = iota // Hour formats time as the number of hours in the unix epoch. Hour // Minute formats time as the number of minutes in the unix epoch. Minute // Second formats time as the number of seconds in the unix epoch. Second // Millisecond formats time as the number of milliseconds in the unix epoch. Millisecond // Microsecond formats time as the number of microseconds in the unix epoch. Microsecond // Nanosecond formats time as the number of nanoseconds in the unix epoch. Nanosecond )
type Transpiler ¶
type Transpiler struct {
Config *Config
// contains filtered or unexported fields
}
Transpiler converts InfluxQL queries into a query spec.
func NewTranspiler ¶
func NewTranspiler(dbrpMappingSvc influxdb.DBRPMappingServiceV2) *Transpiler
func NewTranspilerWithConfig ¶
func NewTranspilerWithConfig(dbrpMappingSvc influxdb.DBRPMappingServiceV2, cfg Config) *Transpiler