Skip to content

Commit 3f4c808

Browse files
committed
Merge remote-tracking branch 'upstream/master' into postgres-query-builder
2 parents 8490ae4 + b464a28 commit 3f4c808

File tree

27 files changed

+178
-113
lines changed

27 files changed

+178
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fig.yml
4343
docker-compose.yml
4444
docker-compose.yaml
4545
/conf/provisioning/**/custom.yaml
46+
/conf/provisioning/**/dev.yaml
4647
/conf/ldap_dev.toml
4748
profile.cov
4849
/grafana

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010
* **Singlestat**: Make colorization of prefix and postfix optional in singlestat [#11892](https://github.com/grafana/grafana/pull/11892), thx [@ApsOps](https://github.com/ApsOps)
1111
* **Table**: Make table sorting stable when null values exist [#12362](https://github.com/grafana/grafana/pull/12362), thx [@bz2](https://github.com/bz2)
1212
* **Prometheus**: Fix graph panel bar width issue in aligned prometheus queries [#12379](https://github.com/grafana/grafana/issues/12379)
13+
* **Prometheus**: Heatmap - fix unhandled error when some points are missing [#12484](https://github.com/grafana/grafana/issues/12484)
1314
* **Variables**: Skip unneeded extra query request when de-selecting variable values used for repeated panels [#8186](https://github.com/grafana/grafana/issues/8186), thx [@mtanda](https://github.com/mtanda)
1415
* **Postgres/MySQL/MSSQL**: Use floor rounding in $__timeGroup macro function [#12460](https://github.com/grafana/grafana/issues/12460), thx [@svenklemm](https://github.com/svenklemm)
16+
* **MySQL/MSSQL**: Use datetime format instead of epoch for $__timeFilter, $__timeFrom and $__timeTo macros [#11618](https://github.com/grafana/grafana/issues/11618) [#11619](https://github.com/grafana/grafana/issues/11619), thx [@AustinWinstanley](https://github.com/AustinWinstanley)
1517
* **Github OAuth**: Allow changes of user info at Github to be synched to Grafana when signing in [#11818](https://github.com/grafana/grafana/issues/11818), thx [@rwaweber](https://github.com/rwaweber)
1618

19+
# 5.2.2 (unreleased)
20+
21+
### Minor
22+
23+
* **Prometheus**: Fix graph panel bar width issue in aligned prometheus queries [#12379](https://github.com/grafana/grafana/issues/12379)
24+
* **Dashboard**: Dashboard links not updated when changing variables [#12506](https://github.com/grafana/grafana/issues/12506)
25+
1726
# 5.2.1 (2018-06-29)
1827

1928
### Minor

devenv/dashboards.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: 1
2+
3+
providers:
4+
- name: 'gdev dashboards'
5+
folder: 'gdev dashboards'
6+
type: file
7+
options:
8+
path: devenv/dev-dashboards
9+

devenv/dashboards/dev-dashboards/dev-dashboards.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

devenv/datasources/default/default.yaml renamed to devenv/datasources.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
apiVersion: 1
22

33
datasources:
4-
- name: Graphite
4+
- name: gdev-graphite
55
type: graphite
66
access: proxy
77
url: http://localhost:8080
88
jsonData:
99
graphiteVersion: "1.1"
10-
11-
- name: Prometheus
10+
11+
- name: gdev-prometheus
1212
type: prometheus
1313
access: proxy
1414
isDefault: true
1515
url: http://localhost:9090
16-
17-
- name: InfluxDB
16+
17+
- name: gdev-influxdb
1818
type: influxdb
1919
access: proxy
2020
database: site
2121
user: grafana
2222
password: grafana
2323
url: http://localhost:8086
24-
jsonData:
24+
jsonData:
2525
timeInterval: "15s"
2626

27-
- name: OpenTsdb
27+
- name: gdev-opentsdb
2828
type: opentsdb
2929
access: proxy
3030
url: http://localhost:4242
31-
jsonData:
31+
jsonData:
3232
tsdbResolution: 1
3333
tsdbVersion: 1
3434

35-
- name: Elastic
35+
- name: gdev-elasticsearch-metrics
3636
type: elasticsearch
3737
access: proxy
3838
database: "[metrics-]YYYY.MM.DD"
3939
url: http://localhost:9200
4040
jsonData:
4141
interval: Daily
4242
timeField: "@timestamp"
43-
44-
- name: MySQL
43+
44+
- name: gdev-mysql
4545
type: mysql
4646
url: localhost:3306
4747
database: grafana
4848
user: grafana
4949
password: password
5050

51-
- name: MSSQL
51+
- name: gdev-mssql
5252
type: mssql
5353
url: localhost:1433
5454
database: grafana
5555
user: grafana
5656
password: "Password!"
5757

58-
- name: Postgres
58+
- name: gdev-postgres
5959
type: postgres
6060
url: localhost:5432
6161
database: grafana
@@ -64,7 +64,7 @@ datasources:
6464
jsonData:
6565
sslmode: "disable"
6666

67-
- name: Cloudwatch
67+
- name: gdev-cloudwatch
6868
type: cloudwatch
6969
editable: true
7070
jsonData:

devenv/setup.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,36 @@ requiresJsonnet() {
2323
}
2424

2525
defaultDashboards() {
26-
requiresJsonnet
27-
28-
ln -s -f -r ./dashboards/dev-dashboards/dev-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
26+
ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
2927
}
3028

3129
defaultDatasources() {
3230
echo "setting up all default datasources using provisioning"
3331

34-
ln -s -f -r ./datasources/default/default.yaml ../conf/provisioning/datasources/custom.yaml
32+
ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
3533
}
3634

3735
usage() {
38-
echo -e "install.sh\n\tThis script installs my basic setup for a debian laptop\n"
36+
echo -e "install.sh\n\tThis script setups dev provision for datasources and dashboards"
3937
echo "Usage:"
4038
echo " bulk-dashboards - create and provisioning 400 dashboards"
41-
echo " default-datasources - provisiong all core datasources"
39+
echo " no args - provisiong core datasources and dev dashboards"
4240
}
4341

4442
main() {
4543
local cmd=$1
4644

47-
if [[ -z "$cmd" ]]; then
48-
usage
49-
exit 1
50-
fi
51-
5245
if [[ $cmd == "bulk-dashboards" ]]; then
5346
bulkDashboard
54-
elif [[ $cmd == "default-datasources" ]]; then
55-
defaultDatasources
56-
elif [[ $cmd == "default-dashboards" ]]; then
57-
defaultDashboards
5847
else
48+
defaultDashboards
49+
defaultDatasources
50+
fi
51+
52+
if [[ -z "$cmd" ]]; then
5953
usage
6054
fi
55+
6156
}
6257

6358
main "$@"

docs/sources/features/datasources/mssql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ Macro example | Description
7777
------------ | -------------
7878
*$__time(dateColumn)* | Will be replaced by an expression to rename the column to *time*. For example, *dateColumn as time*
7979
*$__timeEpoch(dateColumn)* | Will be replaced by an expression to convert a DATETIME column type to unix timestamp and rename it to *time*. <br/>For example, *DATEDIFF(second, '1970-01-01', dateColumn) AS time*
80-
*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. <br/>For example, *dateColumn >= DATEADD(s, 1494410783, '1970-01-01') AND dateColumn <= DATEADD(s, 1494410783, '1970-01-01')*
81-
*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *DATEADD(second, 1494410783, '1970-01-01')*
82-
*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *DATEADD(second, 1494410783, '1970-01-01')*
80+
*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. <br/>For example, *dateColumn BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:06:17Z'*
81+
*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *'2017-04-21T05:01:17Z'*
82+
*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *'2017-04-21T05:06:17Z'*
8383
*$__timeGroup(dateColumn,'5m'[, fillvalue])* | Will be replaced by an expression usable in GROUP BY clause. Providing a *fillValue* of *NULL* or *floating value* will automatically fill empty series in timerange with that value. <br/>For example, *CAST(ROUND(DATEDIFF(second, '1970-01-01', time_column)/300.0, 0) as bigint)\*300*.
8484
*$__timeGroup(dateColumn,'5m', 0)* | Same as above but with a fill parameter so all null values will be converted to the fill value (all null values would be set to zero using this example).
8585
*$__unixEpochFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name with times represented as unix timestamp. For example, *dateColumn > 1494410783 AND dateColumn < 1494497183*

docs/sources/features/datasources/mysql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Macro example | Description
6060
------------ | -------------
6161
*$__time(dateColumn)* | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, *UNIX_TIMESTAMP(dateColumn) as time_sec*
6262
*$__timeEpoch(dateColumn)* | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, *UNIX_TIMESTAMP(dateColumn) as time_sec*
63-
*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. For example, *dateColumn > FROM_UNIXTIME(1494410783) AND dateColumn < FROM_UNIXTIME(1494497183)*
64-
*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *FROM_UNIXTIME(1494410783)*
65-
*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *FROM_UNIXTIME(1494497183)*
63+
*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. For example, *dateColumn BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:06:17Z'*
64+
*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *'2017-04-21T05:01:17Z'*
65+
*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *'2017-04-21T05:06:17Z'*
6666
*$__timeGroup(dateColumn,'5m')* | Will be replaced by an expression usable in GROUP BY clause. For example, *cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed),*
6767
*$__timeGroup(dateColumn,'5m',0)* | Same as above but with a fill parameter so all null values will be converted to the fill value (all null values would be set to zero using this example).
6868
*$__unixEpochFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name with times represented as unix timestamp. For example, *dateColumn > 1494410783 AND dateColumn < 1494497183*

pkg/tsdb/mssql/macros.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ func (m *MsSqlMacroEngine) evaluateMacro(name string, args []string) (string, er
8282
if len(args) == 0 {
8383
return "", fmt.Errorf("missing time column argument for macro %v", name)
8484
}
85-
return fmt.Sprintf("%s >= DATEADD(s, %d, '1970-01-01') AND %s <= DATEADD(s, %d, '1970-01-01')", args[0], m.TimeRange.GetFromAsSecondsEpoch(), args[0], m.TimeRange.GetToAsSecondsEpoch()), nil
85+
86+
return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.TimeRange.GetFromAsTimeUTC().Format(time.RFC3339), m.TimeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil
8687
case "__timeFrom":
87-
return fmt.Sprintf("DATEADD(second, %d, '1970-01-01')", m.TimeRange.GetFromAsSecondsEpoch()), nil
88+
return fmt.Sprintf("'%s'", m.TimeRange.GetFromAsTimeUTC().Format(time.RFC3339)), nil
8889
case "__timeTo":
89-
return fmt.Sprintf("DATEADD(second, %d, '1970-01-01')", m.TimeRange.GetToAsSecondsEpoch()), nil
90+
return fmt.Sprintf("'%s'", m.TimeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil
9091
case "__timeGroup":
9192
if len(args) < 2 {
9293
return "", fmt.Errorf("macro %v needs time column and interval", name)

pkg/tsdb/mssql/macros_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestMacroEngine(t *testing.T) {
4949
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
5050
So(err, ShouldBeNil)
5151

52-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= DATEADD(s, %d, '1970-01-01') AND time_column <= DATEADD(s, %d, '1970-01-01')", from.Unix(), to.Unix()))
52+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
5353
})
5454

5555
Convey("interpolate __timeGroup function", func() {
@@ -96,14 +96,14 @@ func TestMacroEngine(t *testing.T) {
9696
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
9797
So(err, ShouldBeNil)
9898

99-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", from.Unix()))
99+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
100100
})
101101

102102
Convey("interpolate __timeTo function", func() {
103103
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
104104
So(err, ShouldBeNil)
105105

106-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", to.Unix()))
106+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
107107
})
108108

109109
Convey("interpolate __unixEpochFilter function", func() {
@@ -137,21 +137,21 @@ func TestMacroEngine(t *testing.T) {
137137
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
138138
So(err, ShouldBeNil)
139139

140-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= DATEADD(s, %d, '1970-01-01') AND time_column <= DATEADD(s, %d, '1970-01-01')", from.Unix(), to.Unix()))
140+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
141141
})
142142

143143
Convey("interpolate __timeFrom function", func() {
144144
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
145145
So(err, ShouldBeNil)
146146

147-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", from.Unix()))
147+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
148148
})
149149

150150
Convey("interpolate __timeTo function", func() {
151151
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
152152
So(err, ShouldBeNil)
153153

154-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", to.Unix()))
154+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
155155
})
156156

157157
Convey("interpolate __unixEpochFilter function", func() {
@@ -185,21 +185,21 @@ func TestMacroEngine(t *testing.T) {
185185
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
186186
So(err, ShouldBeNil)
187187

188-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= DATEADD(s, %d, '1970-01-01') AND time_column <= DATEADD(s, %d, '1970-01-01')", from.Unix(), to.Unix()))
188+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
189189
})
190190

191191
Convey("interpolate __timeFrom function", func() {
192192
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
193193
So(err, ShouldBeNil)
194194

195-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", from.Unix()))
195+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
196196
})
197197

198198
Convey("interpolate __timeTo function", func() {
199199
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
200200
So(err, ShouldBeNil)
201201

202-
So(sql, ShouldEqual, fmt.Sprintf("select DATEADD(second, %d, '1970-01-01')", to.Unix()))
202+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
203203
})
204204

205205
Convey("interpolate __unixEpochFilter function", func() {

pkg/tsdb/mysql/macros.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ func (m *MySqlMacroEngine) evaluateMacro(name string, args []string) (string, er
7777
if len(args) == 0 {
7878
return "", fmt.Errorf("missing time column argument for macro %v", name)
7979
}
80-
return fmt.Sprintf("%s >= FROM_UNIXTIME(%d) AND %s <= FROM_UNIXTIME(%d)", args[0], m.TimeRange.GetFromAsSecondsEpoch(), args[0], m.TimeRange.GetToAsSecondsEpoch()), nil
80+
81+
return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.TimeRange.GetFromAsTimeUTC().Format(time.RFC3339), m.TimeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil
8182
case "__timeFrom":
82-
return fmt.Sprintf("FROM_UNIXTIME(%d)", m.TimeRange.GetFromAsSecondsEpoch()), nil
83+
return fmt.Sprintf("'%s'", m.TimeRange.GetFromAsTimeUTC().Format(time.RFC3339)), nil
8384
case "__timeTo":
84-
return fmt.Sprintf("FROM_UNIXTIME(%d)", m.TimeRange.GetToAsSecondsEpoch()), nil
85+
return fmt.Sprintf("'%s'", m.TimeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil
8586
case "__timeGroup":
8687
if len(args) < 2 {
8788
return "", fmt.Errorf("macro %v needs time column and interval", name)

pkg/tsdb/mysql/macros_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ func TestMacroEngine(t *testing.T) {
5454
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
5555
So(err, ShouldBeNil)
5656

57-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= FROM_UNIXTIME(%d) AND time_column <= FROM_UNIXTIME(%d)", from.Unix(), to.Unix()))
57+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
5858
})
5959

6060
Convey("interpolate __timeFrom function", func() {
6161
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
6262
So(err, ShouldBeNil)
6363

64-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", from.Unix()))
64+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
6565
})
6666

6767
Convey("interpolate __timeTo function", func() {
6868
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
6969
So(err, ShouldBeNil)
7070

71-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", to.Unix()))
71+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
7272
})
7373

7474
Convey("interpolate __unixEpochFilter function", func() {
@@ -102,21 +102,21 @@ func TestMacroEngine(t *testing.T) {
102102
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
103103
So(err, ShouldBeNil)
104104

105-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= FROM_UNIXTIME(%d) AND time_column <= FROM_UNIXTIME(%d)", from.Unix(), to.Unix()))
105+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
106106
})
107107

108108
Convey("interpolate __timeFrom function", func() {
109109
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
110110
So(err, ShouldBeNil)
111111

112-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", from.Unix()))
112+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
113113
})
114114

115115
Convey("interpolate __timeTo function", func() {
116116
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
117117
So(err, ShouldBeNil)
118118

119-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", to.Unix()))
119+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
120120
})
121121

122122
Convey("interpolate __unixEpochFilter function", func() {
@@ -150,21 +150,21 @@ func TestMacroEngine(t *testing.T) {
150150
sql, err := engine.Interpolate(query, timeRange, "WHERE $__timeFilter(time_column)")
151151
So(err, ShouldBeNil)
152152

153-
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column >= FROM_UNIXTIME(%d) AND time_column <= FROM_UNIXTIME(%d)", from.Unix(), to.Unix()))
153+
So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339)))
154154
})
155155

156156
Convey("interpolate __timeFrom function", func() {
157157
sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom(time_column)")
158158
So(err, ShouldBeNil)
159159

160-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", from.Unix()))
160+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339)))
161161
})
162162

163163
Convey("interpolate __timeTo function", func() {
164164
sql, err := engine.Interpolate(query, timeRange, "select $__timeTo(time_column)")
165165
So(err, ShouldBeNil)
166166

167-
So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", to.Unix()))
167+
So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339)))
168168
})
169169

170170
Convey("interpolate __unixEpochFilter function", func() {

0 commit comments

Comments
 (0)