Skip to content

Commit 7643c0c

Browse files
author
Vladimir Smirnov
committed
aggregate: function should register all short forms as an alias
* This allows groupByNode/groupByNodes to call all available summarizer functions Fixes #466
1 parent 9a825ee commit 7643c0c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

expr/functions/aggregate/function.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ func New(configFile string) []interfaces.FunctionMetadata {
2424
for _, n := range []string{"aggregate"} {
2525
res = append(res, interfaces.FunctionMetadata{Name: n, F: f})
2626
}
27+
28+
// Also register aliases for each and every summarizer
29+
for _, n := range consolidations.AvailableSummarizers {
30+
res = append(res, interfaces.FunctionMetadata{Name: n, F: f})
31+
}
2732
return res
2833
}
2934

@@ -36,7 +41,11 @@ func (f *aggregate) Do(e parser.Expr, from, until int64, values map[parser.Metri
3641

3742
callback, err := e.GetStringArg(1)
3843
if err != nil {
39-
return nil, err
44+
if e.Target() == "aggregate" {
45+
return nil, err
46+
} else {
47+
callback = e.Target()
48+
}
4049
}
4150

4251
// TODO: Implement xFilesFactor

expr/functions/diffSeries/function.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package diffSeries
22

33
import (
44
"fmt"
5+
"math"
6+
"strings"
7+
58
"github.com/go-graphite/carbonapi/expr/helper"
69
"github.com/go-graphite/carbonapi/expr/interfaces"
710
"github.com/go-graphite/carbonapi/expr/types"
811
"github.com/go-graphite/carbonapi/pkg/parser"
9-
"math"
10-
"strings"
1112
)
1213

1314
type diffSeries struct {

0 commit comments

Comments
 (0)