returnfmt.Sprintf("cast(cast(DATEDIFF(second, {d '1970-01-01'}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), %s))/%.0f as int)*%.0f as int)",args[0],interval.Seconds(),interval.Seconds()),nil
case"__unixEpochFilter":
iflen(args)==0{
return"",fmt.Errorf("missing time column argument for macro %v",name)
sql,err:=engine.Interpolate(query,timeRange,"GROUP BY $__timeGroup(time_column,'5m')")
So(err,ShouldBeNil)
So(sql,ShouldEqual,"GROUP BY cast(cast(DATEDIFF(second, {d '1970-01-01'}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time_column))/300 as int)*300 as int)")
})
Convey("interpolate __timeGroup function with spaces around arguments",func(){
sql,err:=engine.Interpolate(query,timeRange,"GROUP BY $__timeGroup(time_column , '5m')")
So(err,ShouldBeNil)
So(sql,ShouldEqual,"GROUP BY cast(cast(DATEDIFF(second, {d '1970-01-01'}, DATEADD(second, DATEDIFF(second,GETDATE(),GETUTCDATE()), time_column))/300 as int)*300 as int)")