Explorar o código

fix rebase error

Sven Klemm %!s(int64=7) %!d(string=hai) anos
pai
achega
d2984f3b0f

+ 2 - 2
pkg/tsdb/postgres/macros.go

@@ -132,9 +132,9 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string,
 		}
 		}
 
 
 		if m.query.DataSource.JsonData.Get("timescaledb").MustBool() {
 		if m.query.DataSource.JsonData.Get("timescaledb").MustBool() {
-			return fmt.Sprintf("time_bucket('%vs',%s) AS time", interval.Seconds(), args[0]), nil
+			return fmt.Sprintf("time_bucket('%vs',%s)", interval.Seconds(), args[0]), nil
 		} else {
 		} else {
-			return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v AS time", args[0], interval.Seconds(), interval.Seconds()), nil
+			return fmt.Sprintf("floor(extract(epoch from %s)/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil
 		}
 		}
 	case "__timeGroupAlias":
 	case "__timeGroupAlias":
 		tg, err := m.evaluateMacro("__timeGroup", args)
 		tg, err := m.evaluateMacro("__timeGroup", args)

+ 2 - 2
pkg/tsdb/postgres/macros_test.go

@@ -92,7 +92,7 @@ func TestMacroEngine(t *testing.T) {
 				sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column,'5m')")
 				sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column,'5m')")
 				So(err, ShouldBeNil)
 				So(err, ShouldBeNil)
 
 
-				So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time")
+				So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)")
 			})
 			})
 
 
 			Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() {
 			Convey("interpolate __timeGroup function with spaces between args and TimescaleDB enabled", func() {
@@ -100,7 +100,7 @@ func TestMacroEngine(t *testing.T) {
 				sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column , '5m')")
 				sql, err := engine.Interpolate(queryTS, timeRange, "GROUP BY $__timeGroup(time_column , '5m')")
 				So(err, ShouldBeNil)
 				So(err, ShouldBeNil)
 
 
-				So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column) AS time")
+				So(sql, ShouldEqual, "GROUP BY time_bucket('300s',time_column)")
 			})
 			})
 
 
 			Convey("interpolate __timeTo function", func() {
 			Convey("interpolate __timeTo function", func() {

+ 1 - 0
pkg/tsdb/postgres/postgres_test.go

@@ -311,6 +311,7 @@ func TestPostgres(t *testing.T) {
 			query := &tsdb.TsdbQuery{
 			query := &tsdb.TsdbQuery{
 				Queries: []*tsdb.Query{
 				Queries: []*tsdb.Query{
 					{
 					{
+						DataSource: &models.DataSource{JsonData: simplejson.New()},
 						Model: simplejson.NewFromAny(map[string]interface{}{
 						Model: simplejson.NewFromAny(map[string]interface{}{
 							"rawSql": "SELECT $__timeGroup(time, '5m', previous), avg(value) as value FROM metric GROUP BY 1 ORDER BY 1",
 							"rawSql": "SELECT $__timeGroup(time, '5m', previous), avg(value) as value FROM metric GROUP BY 1 ORDER BY 1",
 							"format": "time_series",
 							"format": "time_series",