add __timeGroup macro for mysql (#9596)

* add __timeGroup macro for mysql

* put example __timeGroup query in frontend help

* do __timeGroup interval parsing in go similar to mysql

* ignore whitespace around interval
This commit is contained in:
Sven Klemm
2017-10-27 11:26:25 +02:00
committed by Daniel Lee
parent 6aa0f35012
commit 34da0711ab
6 changed files with 42 additions and 12 deletions

View File

@ -45,7 +45,7 @@ func TestMacroEngine(t *testing.T) {
sql, err := engine.Interpolate(timeRange, "GROUP BY $__timeGroup(time_column,'5m')")
So(err, ShouldBeNil)
So(sql, ShouldEqual, "GROUP BY (extract(epoch from \"time_column\")/extract(epoch from '5m'::interval))::int*extract(epoch from '5m'::interval)")
So(sql, ShouldEqual, "GROUP BY (extract(epoch from \"time_column\")/300)::bigint*300")
})
Convey("interpolate __timeTo function", func() {