Skip to content

Commit

Permalink
set appropriate clickhouse aggregation functions for last and first
Browse files Browse the repository at this point in the history
  • Loading branch information
mchrome committed Jun 6, 2024
1 parent 64e702d commit 36d80d4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions render/data/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,22 @@ func (tt *Targets) GetRequestedAggregation(target string) string {
ffName := filteringFunc.GetName()
ffArgs := filteringFunc.GetArguments()
if ffName == graphiteConsolidationFunction && len(ffArgs) > 0 {
switch ffArgs[0] {
// 'last' in graphite == clickhouse aggregate function 'anyLast'
case "last":
return "anyLast"
// 'first' in graphite == clickhouse aggregate function 'any'
case "first":
return "any"
// Graphite standard supports both average and avg.
// It is the only aggregation that has two aliases.
// https://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.consolidateBy
if ffArgs[0] == "average" {
case "average":
return "avg"
// avg, sum, max, min have the same name in clickhouse
default:
return ffArgs[0]
}
return ffArgs[0]
}
}
}
Expand Down

0 comments on commit 36d80d4

Please sign in to comment.