mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 09:21:47 +08:00
postgres: tests: improve float64-conversion tests (#80627)
postgres: more tests
This commit is contained in:
@ -121,6 +121,7 @@ func TestIntegrationPostgresSnapshots(t *testing.T) {
|
|||||||
{format: "time_series", name: "simple"},
|
{format: "time_series", name: "simple"},
|
||||||
{format: "time_series", name: "7x_compat_metric_label"},
|
{format: "time_series", name: "7x_compat_metric_label"},
|
||||||
{format: "time_series", name: "convert_to_float64"},
|
{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_null"},
|
||||||
{format: "time_series", name: "fill_previous"},
|
{format: "time_series", name: "fill_previous"},
|
||||||
{format: "time_series", name: "fill_value"},
|
{format: "time_series", name: "fill_value"},
|
||||||
|
@ -9,14 +9,15 @@
|
|||||||
// "executedQueryString": "SELECT * FROM tbl"
|
// "executedQueryString": "SELECT * FROM tbl"
|
||||||
// }
|
// }
|
||||||
// Name:
|
// Name:
|
||||||
// Dimensions: 11 Fields by 1 Rows
|
// 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 |
|
// | 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 |
|
// | 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 |
|
// | 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: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. 🌟
|
// 🌟 This was machine generated. Do not edit. 🌟
|
||||||
@ -49,12 +50,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -65,12 +61,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -81,12 +72,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -97,12 +83,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -113,12 +94,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -129,12 +105,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -145,12 +116,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -161,12 +127,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -177,12 +138,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -193,12 +149,7 @@
|
|||||||
"nullable": true
|
"nullable": true
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"c1": "one",
|
"t": "one"
|
||||||
"c1nn": "two",
|
|
||||||
"c2": "three",
|
|
||||||
"c2nn": "four",
|
|
||||||
"c3": "five ",
|
|
||||||
"c3nn": "six "
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -206,37 +157,48 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"values": [
|
"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
|
-- 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 (
|
CREATE TEMPORARY TABLE tbl (
|
||||||
"time" timestamp with time zone,
|
"time" timestamp with time zone,
|
||||||
v1 double precision,
|
v1 double precision,
|
||||||
v1nn double precision NOT NULL,
|
v1nn double precision NOT NULL,
|
||||||
v2 real,
|
v2 real,
|
||||||
v2nn real NOT NULL,
|
v2nn real NOT NULL,
|
||||||
c1 text,
|
t text,
|
||||||
c1nn text NOT NULL,
|
|
||||||
c2 varchar(10),
|
|
||||||
c2nn varchar(10) NOT NULL,
|
|
||||||
c3 char(10),
|
|
||||||
c3nn char(10) NOT NULL,
|
|
||||||
x1 smallint,
|
x1 smallint,
|
||||||
x1nn smallint NOT NULL,
|
x1nn smallint NOT NULL,
|
||||||
x2 integer,
|
x2 integer,
|
||||||
@ -22,9 +17,13 @@ CREATE TEMPORARY TABLE tbl (
|
|||||||
|
|
||||||
INSERT INTO tbl ("time",
|
INSERT INTO tbl ("time",
|
||||||
v1, v1nn, v2, v2nn,
|
v1, v1nn, v2, v2nn,
|
||||||
c1, c1nn, c2, c2nn, c3, c3nn,
|
t,
|
||||||
x1, x1nn, x2, x2nn, x3, x3nn) VALUES
|
x1, x1nn, x2, x2nn, x3, x3nn) VALUES
|
||||||
('2023-12-21 11:30:03 UTC',
|
('2023-12-21 11:30:03 UTC',
|
||||||
10.1, 11.1, 12.1, 13.1,
|
10.1, 11.1, 12.1, 13.1,
|
||||||
'one', 'two', 'three', 'four', 'five', 'six',
|
'one',
|
||||||
101, 102, 103, 104, 105, 106);
|
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);
|
97
pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.golden.jsonc
vendored
Normal file
97
pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.golden.jsonc
vendored
Normal file
@ -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
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
22
pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.sql
vendored
Normal file
22
pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/convert_to_float64_not.sql
vendored
Normal file
@ -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');
|
Reference in New Issue
Block a user