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 selectorpull/10616/head
parent
796fd7217e
commit
05a2feb1fc
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,7 +14,7 @@ type CountOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var countSignature = query.DefaultFunctionSignature()
|
||||
var countSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(CountKind, createCountOpSpec, countSignature)
|
||||
|
|
|
@ -19,7 +19,7 @@ type CovarianceOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var covarianceSignature = query.DefaultFunctionSignature()
|
||||
var covarianceSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
covarianceSignature.Params["pearsonr"] = semantic.Bool
|
||||
|
|
|
@ -14,7 +14,7 @@ type FirstOpSpec struct {
|
|||
execute.SelectorConfig
|
||||
}
|
||||
|
||||
var firstSignature = query.DefaultFunctionSignature()
|
||||
var firstSignature = execute.DefaultSelectorSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(FirstKind, createFirstOpSpec, firstSignature)
|
||||
|
|
|
@ -17,7 +17,7 @@ type IntegralOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var integralSignature = query.DefaultFunctionSignature()
|
||||
var integralSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
integralSignature.Params["unit"] = semantic.Duration
|
||||
|
|
|
@ -14,7 +14,7 @@ type LastOpSpec struct {
|
|||
execute.SelectorConfig
|
||||
}
|
||||
|
||||
var lastSignature = query.DefaultFunctionSignature()
|
||||
var lastSignature = execute.DefaultSelectorSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(LastKind, createLastOpSpec, lastSignature)
|
||||
|
|
|
@ -14,7 +14,7 @@ type MaxOpSpec struct {
|
|||
execute.SelectorConfig
|
||||
}
|
||||
|
||||
var maxSignature = query.DefaultFunctionSignature()
|
||||
var maxSignature = execute.DefaultSelectorSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(MaxKind, createMaxOpSpec, maxSignature)
|
||||
|
|
|
@ -15,7 +15,7 @@ type MeanOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var meanSignature = query.DefaultFunctionSignature()
|
||||
var meanSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(MeanKind, createMeanOpSpec, meanSignature)
|
||||
|
|
|
@ -14,7 +14,7 @@ type MinOpSpec struct {
|
|||
execute.SelectorConfig
|
||||
}
|
||||
|
||||
var minSignature = query.DefaultFunctionSignature()
|
||||
var minSignature = execute.DefaultSelectorSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(MinKind, createMinOpSpec, minSignature)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ type SampleOpSpec struct {
|
|||
execute.SelectorConfig
|
||||
}
|
||||
|
||||
var sampleSignature = query.DefaultFunctionSignature()
|
||||
var sampleSignature = execute.DefaultSelectorSignature()
|
||||
|
||||
func init() {
|
||||
sampleSignature.Params["n"] = semantic.Int
|
||||
|
|
|
@ -15,7 +15,7 @@ type SkewOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var skewSignature = query.DefaultFunctionSignature()
|
||||
var skewSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(SkewKind, createSkewOpSpec, skewSignature)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,7 +15,7 @@ type StddevOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var stddevSignature = query.DefaultFunctionSignature()
|
||||
var stddevSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(StddevKind, createStddevOpSpec, stddevSignature)
|
||||
|
|
|
@ -14,7 +14,7 @@ type SumOpSpec struct {
|
|||
execute.AggregateConfig
|
||||
}
|
||||
|
||||
var sumSignature = query.DefaultFunctionSignature()
|
||||
var sumSignature = execute.DefaultAggregateSignature()
|
||||
|
||||
func init() {
|
||||
query.RegisterFunction(SumKind, createSumOpSpec, sumSignature)
|
||||
|
|
Loading…
Reference in New Issue