postgres: improved tests (#84677)

* postgres: tests: better test aligning time-series results

* postgres: add snapshot test for a backward-compat code
This commit is contained in:
Gábor Farkas
2024-03-26 10:22:58 +01:00
committed by GitHub
parent 28ecd83987
commit c835022861
7 changed files with 267 additions and 2 deletions

View File

@ -0,0 +1,65 @@
// 🌟 This was machine generated. Do not edit. 🌟
//
// Frame[0] {
// "typeVersion": [
// 0,
// 0
// ],
// "executedQueryString": "SELECT floor(extract(epoch from \"t\")/300)*300 AS \"time\",avg(v) FROM tbl GROUP BY 1"
// }
// Name:
// Dimensions: 2 Fields by 1 Rows
// +-------------------------------+------------------+
// | Name: time | Name: avg |
// | Labels: | Labels: |
// | Type: []*time.Time | Type: []*float64 |
// +-------------------------------+------------------+
// | 2023-12-24 14:30:00 +0000 UTC | 42 |
// +-------------------------------+------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"status": 200,
"frames": [
{
"schema": {
"meta": {
"typeVersion": [
0,
0
],
"executedQueryString": "SELECT floor(extract(epoch from \"t\")/300)*300 AS \"time\",avg(v) FROM tbl GROUP BY 1"
},
"fields": [
{
"name": "time",
"type": "time",
"typeInfo": {
"frame": "time.Time",
"nullable": true
}
},
{
"name": "avg",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
}
}
]
},
"data": {
"values": [
[
1703428200000
],
[
42
]
]
}
}
]
}

View File

@ -0,0 +1,10 @@
-- SELECT $__timeGroup("t",5m,NULL),avg(v) FROM tbl GROUP BY 1
-- we change behavior based on what follows the timegroup, see:
-- https://github.com/grafana/grafana/blob/0b4c81158ea32a671e7788b888b086082343407c/pkg/tsdb/grafana-postgresql-datasource/macros.go#L36
CREATE TEMPORARY TABLE tbl (
t timestamp with time zone,
v double precision
);
INSERT INTO tbl (t, v) VALUES
('2023-12-24 14:30:03 UTC', 42);

View File

@ -0,0 +1,65 @@
// 🌟 This was machine generated. Do not edit. 🌟
//
// Frame[0] {
// "typeVersion": [
// 0,
// 0
// ],
// "executedQueryString": "SELECT floor(extract(epoch from \"t\")/300)*300 ,avg(v) FROM tbl GROUP BY 1"
// }
// Name:
// Dimensions: 2 Fields by 1 Rows
// +------------------+------------------+
// | Name: ?column? | Name: avg |
// | Labels: | Labels: |
// | Type: []*float64 | Type: []*float64 |
// +------------------+------------------+
// | 1.7034282e+09 | 42 |
// +------------------+------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"status": 200,
"frames": [
{
"schema": {
"meta": {
"typeVersion": [
0,
0
],
"executedQueryString": "SELECT floor(extract(epoch from \"t\")/300)*300 ,avg(v) FROM tbl GROUP BY 1"
},
"fields": [
{
"name": "?column?",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
}
},
{
"name": "avg",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
}
}
]
},
"data": {
"values": [
[
1703428200
],
[
42
]
]
}
}
]
}

View File

@ -0,0 +1,10 @@
-- SELECT $__timeGroup("t",5m,NULL) ,avg(v) FROM tbl GROUP BY 1
-- we change behavior based on what follows the timegroup, see:
-- https://github.com/grafana/grafana/blob/0b4c81158ea32a671e7788b888b086082343407c/pkg/tsdb/grafana-postgresql-datasource/macros.go#L36
CREATE TEMPORARY TABLE tbl (
t timestamp with time zone,
v double precision
);
INSERT INTO tbl (t, v) VALUES
('2023-12-24 14:30:03 UTC', 42);