Added default signature generators for Selector and Aggregate configs and update the functions that need them (#690)

* Added default signature generators for Selector and Aggregate configs and update the functions that need them

* fix to percentile to collect the correct arguments for both aggregate and selector
pull/10616/head
Adam 2018-08-27 17:20:18 -04:00 committed by GitHub
parent 796fd7217e
commit 05a2feb1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 48 additions and 15 deletions

View File

@ -29,6 +29,19 @@ var DefaultAggregateConfig = AggregateConfig{
TimeDst: DefaultTimeColLabel,
}
func DefaultAggregateSignature() semantic.FunctionSignature {
return semantic.FunctionSignature{
Params: map[string]semantic.Type{
query.TableParameter: query.TableObjectType,
"columns": semantic.NewArrayType(semantic.String),
"timeSrc": semantic.String,
"timeDst": semantic.String,
},
ReturnType: query.TableObjectType,
PipeArgument: query.TableParameter,
}
}
func (c AggregateConfig) Copy() AggregateConfig {
nc := c
if c.Columns != nil {

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/influxdata/platform/query"
"github.com/influxdata/platform/query/semantic"
)
type selectorTransformation struct {
@ -26,6 +27,17 @@ func (c *SelectorConfig) ReadArgs(args query.Arguments) error {
return nil
}
func DefaultSelectorSignature() semantic.FunctionSignature {
return semantic.FunctionSignature{
Params: map[string]semantic.Type{
query.TableParameter: query.TableObjectType,
"column": semantic.String,
},
ReturnType: query.TableObjectType,
PipeArgument: query.TableParameter,
}
}
type rowSelectorTransformation struct {
selectorTransformation
selector RowSelector

View File

@ -14,7 +14,7 @@ type CountOpSpec struct {
execute.AggregateConfig
}
var countSignature = query.DefaultFunctionSignature()
var countSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(CountKind, createCountOpSpec, countSignature)

View File

@ -19,7 +19,7 @@ type CovarianceOpSpec struct {
execute.AggregateConfig
}
var covarianceSignature = query.DefaultFunctionSignature()
var covarianceSignature = execute.DefaultAggregateSignature()
func init() {
covarianceSignature.Params["pearsonr"] = semantic.Bool

View File

@ -14,7 +14,7 @@ type FirstOpSpec struct {
execute.SelectorConfig
}
var firstSignature = query.DefaultFunctionSignature()
var firstSignature = execute.DefaultSelectorSignature()
func init() {
query.RegisterFunction(FirstKind, createFirstOpSpec, firstSignature)

View File

@ -17,7 +17,7 @@ type IntegralOpSpec struct {
execute.AggregateConfig
}
var integralSignature = query.DefaultFunctionSignature()
var integralSignature = execute.DefaultAggregateSignature()
func init() {
integralSignature.Params["unit"] = semantic.Duration

View File

@ -14,7 +14,7 @@ type LastOpSpec struct {
execute.SelectorConfig
}
var lastSignature = query.DefaultFunctionSignature()
var lastSignature = execute.DefaultSelectorSignature()
func init() {
query.RegisterFunction(LastKind, createLastOpSpec, lastSignature)

View File

@ -14,7 +14,7 @@ type MaxOpSpec struct {
execute.SelectorConfig
}
var maxSignature = query.DefaultFunctionSignature()
var maxSignature = execute.DefaultSelectorSignature()
func init() {
query.RegisterFunction(MaxKind, createMaxOpSpec, maxSignature)

View File

@ -15,7 +15,7 @@ type MeanOpSpec struct {
execute.AggregateConfig
}
var meanSignature = query.DefaultFunctionSignature()
var meanSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(MeanKind, createMeanOpSpec, meanSignature)

View File

@ -14,7 +14,7 @@ type MinOpSpec struct {
execute.SelectorConfig
}
var minSignature = query.DefaultFunctionSignature()
var minSignature = execute.DefaultSelectorSignature()
func init() {
query.RegisterFunction(MinKind, createMinOpSpec, minSignature)

View File

@ -27,12 +27,15 @@ type PercentileOpSpec struct {
Percentile float64 `json:"percentile"`
Compression float64 `json:"compression"`
Method string `json:"method"`
// percentile is either an aggregate, or a selector based on the options
execute.AggregateConfig
execute.SelectorConfig
}
var percentileSignature = query.DefaultFunctionSignature()
var percentileSignature = execute.DefaultAggregateSignature()
func init() {
percentileSignature.Params["column"] = semantic.String
percentileSignature.Params["p"] = semantic.Float
percentileSignature.Params["compression"] = semantic.Float
percentileSignature.Params["method"] = semantic.String
@ -95,6 +98,10 @@ func createPercentileOpSpec(args query.Arguments, a *query.Administration) (quer
return nil, err
}
if err := spec.SelectorConfig.ReadArgs(args); err != nil {
return nil, err
}
return spec, nil
}

View File

@ -19,7 +19,7 @@ type SampleOpSpec struct {
execute.SelectorConfig
}
var sampleSignature = query.DefaultFunctionSignature()
var sampleSignature = execute.DefaultSelectorSignature()
func init() {
sampleSignature.Params["n"] = semantic.Int

View File

@ -15,7 +15,7 @@ type SkewOpSpec struct {
execute.AggregateConfig
}
var skewSignature = query.DefaultFunctionSignature()
var skewSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(SkewKind, createSkewOpSpec, skewSignature)

View File

@ -6,14 +6,15 @@ import (
"github.com/influxdata/platform/query"
"github.com/influxdata/platform/query/execute"
"github.com/influxdata/platform/query/plan"
"github.com/influxdata/platform/query/semantic"
)
// SpreadKind is the registration name for Flux, query, plan, and execution.
const SpreadKind = "spread"
var spreadSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(SpreadKind, createSpreadOpSpec, semantic.FunctionSignature{})
query.RegisterFunction(SpreadKind, createSpreadOpSpec, spreadSignature)
query.RegisterOpSpec(SpreadKind, newSpreadOp)
plan.RegisterProcedureSpec(SpreadKind, newSpreadProcedure, SpreadKind)
execute.RegisterTransformation(SpreadKind, createSpreadTransformation)

View File

@ -15,7 +15,7 @@ type StddevOpSpec struct {
execute.AggregateConfig
}
var stddevSignature = query.DefaultFunctionSignature()
var stddevSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(StddevKind, createStddevOpSpec, stddevSignature)

View File

@ -14,7 +14,7 @@ type SumOpSpec struct {
execute.AggregateConfig
}
var sumSignature = query.DefaultFunctionSignature()
var sumSignature = execute.DefaultAggregateSignature()
func init() {
query.RegisterFunction(SumKind, createSumOpSpec, sumSignature)