Added unixEpochNanoTo and unixEpochNanoFrom macros to postgresql

This commit is contained in:
Ander Arguiñano
2019-01-03 21:31:47 +01:00
parent 4d8d2a9690
commit 9105625f24
2 changed files with 17 additions and 0 deletions

View File

@ -127,6 +127,10 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string,
return "", fmt.Errorf("missing time column argument for macro %v", name)
}
return fmt.Sprintf("%s >= %d AND %s <= %d", args[0], m.timeRange.GetFromAsTimeUTC().UnixNano(), args[0], m.timeRange.GetToAsTimeUTC().UnixNano()), nil
case "__unixEpochNanoFrom":
return fmt.Sprintf("'%d'", m.timeRange.GetFromAsTimeUTC().UnixNano()), nil
case "__unixEpochNanoTo":
return fmt.Sprintf("'%d'", m.timeRange.GetToAsTimeUTC().UnixNano()), nil
case "__unixEpochGroup":
if len(args) < 2 {
return "", fmt.Errorf("macro %v needs time column and interval and optional fill value", name)