remove postgresversion and convert unix timestamp in go

This commit is contained in:
Sven Klemm
2018-04-15 22:14:13 +02:00
parent 9b61ffb48a
commit 6d3da9a73d
4 changed files with 5 additions and 89 deletions

View File

@ -83,15 +83,7 @@ func (m *PostgresMacroEngine) evaluateMacro(name string, args []string) (string,
return "", fmt.Errorf("missing time column argument for macro %v", name)
}
pg_version := m.Query.DataSource.JsonData.Get("postgresVersion").MustInt(0)
if pg_version >= 80100 {
// postgres has to_timestamp(double) starting with 8.1
return fmt.Sprintf("%s BETWEEN to_timestamp(%d) AND to_timestamp(%d)", args[0], m.TimeRange.GetFromAsSecondsEpoch(), m.TimeRange.GetToAsSecondsEpoch()), nil
}
// dont use to_timestamp in this macro for redshift compatibility #9566
return fmt.Sprintf("%s BETWEEN 'epoch'::timestamptz + %d * '1s'::interval AND 'epoch'::timestamptz + %d * '1s'::interval", args[0], m.TimeRange.GetFromAsSecondsEpoch(), m.TimeRange.GetToAsSecondsEpoch()), nil
return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.TimeRange.MustGetFrom().UTC().Format(time.RFC3339), m.TimeRange.MustGetTo().UTC().Format(time.RFC3339)), nil
case "__timeFrom":
return fmt.Sprintf("to_timestamp(%d)", m.TimeRange.GetFromAsSecondsEpoch()), nil
case "__timeTo":