File: aggr.go

package info (click to toggle)
golang-github-victoriametrics-metricsql 0.49.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 272 kB
  • sloc: makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package metricsql

import (
	"strings"
)

var aggrFuncs = map[string]bool{
	"any":            true,
	"avg":            true,
	"bottomk":        true,
	"bottomk_avg":    true,
	"bottomk_max":    true,
	"bottomk_median": true,
	"bottomk_last":   true,
	"bottomk_min":    true,
	"count":          true,
	"count_values":   true,
	"distinct":       true,
	"geomean":        true,
	"group":          true,
	"histogram":      true,
	"limitk":         true,
	"mad":            true,
	"max":            true,
	"median":         true,
	"min":            true,
	"mode":           true,
	"outliers_mad":   true,
	"outliersk":      true,
	"quantile":       true,
	"quantiles":      true,
	"stddev":         true,
	"stdvar":         true,
	"sum":            true,
	"sum2":           true,
	"topk":           true,
	"topk_avg":       true,
	"topk_max":       true,
	"topk_median":    true,
	"topk_last":      true,
	"topk_min":       true,
	"zscore":         true,
}

func isAggrFunc(s string) bool {
	s = strings.ToLower(s)
	return aggrFuncs[s]
}

func isAggrFuncModifier(s string) bool {
	s = strings.ToLower(s)
	switch s {
	case "by", "without":
		return true
	default:
		return false
	}
}