postgres: tests: improve float64-conversion tests (#80627)

postgres: more tests
pull/80621/head
Gábor Farkas 2 years ago committed by GitHub
parent 89089efc98
commit 4291bf4d69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      pkg/tsdb/grafana-postgresql-datasource/postgres_snapshot_test.go
  2. 120
      pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64.golden.jsonc
  3. 19
      pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64.sql
  4. 97
      pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.golden.jsonc
  5. 22
      pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.sql

@ -121,6 +121,7 @@ func TestIntegrationPostgresSnapshots(t *testing.T) {
{format: "time_series", name: "simple"},
{format: "time_series", name: "7x_compat_metric_label"},
{format: "time_series", name: "convert_to_float64"},
{format: "time_series", name: "convert_to_float64_not"},
{format: "time_series", name: "fill_null"},
{format: "time_series", name: "fill_previous"},
{format: "time_series", name: "fill_value"},

@ -9,14 +9,15 @@
// "executedQueryString": "SELECT * FROM tbl"
// }
// Name:
// Dimensions: 11 Fields by 1 Rows
// +-------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
// | Name: Time | Name: v1 | Name: v1nn | Name: v2 | Name: v2nn | Name: x1 | Name: x1nn | Name: x2 | Name: x2nn | Name: x3 | Name: x3nn |
// | Labels: | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six |
// | Type: []time.Time | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 |
// +-------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
// | 2023-12-21 11:30:03 +0000 UTC | 10.1 | 11.1 | 12.1 | 13.1 | 101 | 102 | 103 | 104 | 105 | 106 |
// +-------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
// Dimensions: 11 Fields by 2 Rows
// +-------------------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+
// | Name: Time | Name: v1 | Name: v1nn | Name: v2 | Name: v2nn | Name: x1 | Name: x1nn | Name: x2 | Name: x2nn | Name: x3 | Name: x3nn |
// | Labels: | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one | Labels: t=one |
// | Type: []time.Time | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 | Type: []*float64 |
// +-------------------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+
// | 2023-12-21 11:30:03 +0000 UTC | 10.1 | 11.1 | 12.1 | 13.1 | 101 | 102 | 103 | 104 | 105 | 106 |
// | 2023-12-21 11:31:03 +0000 UTC | null | 21.1 | null | 23.1 | null | 202 | null | 204 | null | 206 |
// +-------------------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
@ -49,12 +50,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -65,12 +61,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -81,12 +72,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -97,12 +83,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -113,12 +94,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -129,12 +105,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -145,12 +116,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -161,12 +127,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -177,12 +138,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
},
{
@ -193,12 +149,7 @@
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
"t": "one"
}
}
]
@ -206,37 +157,48 @@
"data": {
"values": [
[
1703158203000
1703158203000,
1703158263000
],
[
10.1
10.1,
null
],
[
11.1
11.1,
21.1
],
[
12.1
12.1,
null
],
[
13.1
13.1,
23.1
],
[
101
101,
null
],
[
102
102,
202
],
[
103
103,
null
],
[
104
104,
204
],
[
105
105,
null
],
[
106
106,
206
]
]
}

@ -1,17 +1,12 @@
-- SELECT * FROM tbl
-- in timeseries mode, most fields gets converted to float6
-- in timeseries mode, most fields gets converted to float64
CREATE TEMPORARY TABLE tbl (
"time" timestamp with time zone,
v1 double precision,
v1nn double precision NOT NULL,
v2 real,
v2nn real NOT NULL,
c1 text,
c1nn text NOT NULL,
c2 varchar(10),
c2nn varchar(10) NOT NULL,
c3 char(10),
c3nn char(10) NOT NULL,
t text,
x1 smallint,
x1nn smallint NOT NULL,
x2 integer,
@ -22,9 +17,13 @@ CREATE TEMPORARY TABLE tbl (
INSERT INTO tbl ("time",
v1, v1nn, v2, v2nn,
c1, c1nn, c2, c2nn, c3, c3nn,
t,
x1, x1nn, x2, x2nn, x3, x3nn) VALUES
('2023-12-21 11:30:03 UTC',
10.1, 11.1, 12.1, 13.1,
'one', 'two', 'three', 'four', 'five', 'six',
101, 102, 103, 104, 105, 106);
'one',
101, 102, 103, 104, 105, 106),
('2023-12-21 11:31:03 UTC',
NULL, 21.1, NULL, 23.1,
'one',
NULL, 202, NULL, 204, NULL, 206);

@ -0,0 +1,97 @@
// 🌟 This was machine generated. Do not edit. 🌟
//
// Frame[0] {
// "type": "timeseries-wide",
// "typeVersion": [
// 0,
// 0
// ],
// "executedQueryString": "SELECT * FROM tbl"
// }
// Name:
// Dimensions: 3 Fields by 2 Rows
// +-------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------------------------+
// | Name: Time | Name: v | Name: v |
// | Labels: | Labels: c1=, c1nn=twelve, c2=, c2nn=fourteen, c3=, c3nn=sixteen | Labels: c1=one, c1nn=two, c2=three, c2nn=four, c3=five , c3nn=six |
// | Type: []time.Time | Type: []*float64 | Type: []*float64 |
// +-------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------------------------+
// | 2023-12-21 11:30:03 +0000 UTC | null | 10.1 |
// | 2023-12-21 11:31:03 +0000 UTC | 20.1 | null |
// +-------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------------------------+
//
//
// 🌟 This was machine generated. Do not edit. 🌟
{
"status": 200,
"frames": [
{
"schema": {
"meta": {
"type": "timeseries-wide",
"typeVersion": [
0,
0
],
"executedQueryString": "SELECT * FROM tbl"
},
"fields": [
{
"name": "Time",
"type": "time",
"typeInfo": {
"frame": "time.Time"
}
},
{
"name": "v",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
},
"labels": {
"c1": "",
"c1nn": "twelve",
"c2": "",
"c2nn": "fourteen",
"c3": "",
"c3nn": "sixteen "
}
},
{
"name": "v",
"type": "number",
"typeInfo": {
"frame": "float64",
"nullable": true
},
"labels": {
"c1": "one",
"c1nn": "two",
"c2": "three",
"c2nn": "four",
"c3": "five ",
"c3nn": "six "
}
}
]
},
"data": {
"values": [
[
1703158203000,
1703158263000
],
[
null,
20.1
],
[
10.1,
null
]
]
}
}
]
}

@ -0,0 +1,22 @@
-- SELECT * FROM tbl
-- in timeseries mode, most fields gets converted to float64, but text-fields should stay text
CREATE TEMPORARY TABLE tbl (
"time" timestamp with time zone,
v double precision NOT NULL,
c1 text,
c1nn text NOT NULL,
c2 varchar(10),
c2nn varchar(10) NOT NULL,
c3 char(10),
c3nn char(10) NOT NULL
);
INSERT INTO tbl ("time",
v,
c1, c1nn, c2, c2nn, c3, c3nn) VALUES
('2023-12-21 11:30:03 UTC',
10.1,
'one', 'two', 'three', 'four', 'five', 'six'),
('2023-12-21 11:31:03 UTC',
20.1,
NULL, 'twelve', NULL, 'fourteen', NULL, 'sixteen');
Loading…
Cancel
Save