Skip to content

Commit

Permalink
add nan value test
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
  • Loading branch information
waynexia committed Jun 27, 2023
1 parent f0a39c2 commit fa0a032
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 1 deletion.
31 changes: 31 additions & 0 deletions tests/cases/standalone/common/insert/special_value.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
create table data (ts timestamp(3) time index, val double);

Affected Rows: 0

insert into data values
(0, 'infinity'::double),
(1, '-infinity'::double),
(2, 'nan'::double),
(3, 'NaN'::double);

Affected Rows: 4

select * from data;

+-------------------------+------+
| ts | val |
+-------------------------+------+
| 1970-01-01T00:00:00 | inf |
| 1970-01-01T00:00:00.001 | -inf |
| 1970-01-01T00:00:00.002 | NaN |
| 1970-01-01T00:00:00.003 | NaN |
+-------------------------+------+

insert into data values (4, 'infinityyyy'::double);

Error: 3001(EngineExecuteQuery), Cast error: Cannot cast string 'infinityyyy' to value of Float64 type

drop table data;

Affected Rows: 1

13 changes: 13 additions & 0 deletions tests/cases/standalone/common/insert/special_value.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
create table data (ts timestamp(3) time index, val double);

insert into data values
(0, 'infinity'::double),
(1, '-infinity'::double),
(2, 'nan'::double),
(3, 'NaN'::double);

select * from data;

insert into data values (4, 'infinityyyy'::double);

drop table data;
27 changes: 27 additions & 0 deletions tests/cases/standalone/common/tql/aggr_over_time.result
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,30 @@ drop table data;

Affected Rows: 1

create table data (ts timestamp(3) time index, val double, ty string primary key);

Affected Rows: 0

insert into data values
(0, 2::double, 'numbers'),
(10000, 0::double, 'numbers'),
(20000, 3::double, 'numbers'),
(0, 2::double, 'some_nan'),
(10000, 0::double, 'some_nan'),
(20000, 'NaN'::double, 'some_nan'),
(0, 2::double, 'some_nan2'),
(10000, 'NaN'::double, 'some_nan2'),
(20000, 1::double, 'some_nan2'),
(0, 'NaN'::double, 'some_nan3'),
(10000, 0::double, 'some_nan3'),
(20000, 1::double, 'some_nan3'),
(0, 'NaN'::double, 'only_nan'),
(10000, 'NaN'::double, 'only_nan'),
(20000, 'NaN'::double, 'only_nan');

Affected Rows: 15

drop table data;

Affected Rows: 1

54 changes: 53 additions & 1 deletion tests/cases/standalone/common/tql/aggr_over_time.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,56 @@ insert into data values

drop table data;

-- Some cases are not ported because insert NaN/Inf is not supported yet
-- Port from functions.test L773 - L802, commit 001ee2620e094970e5657ce39275b2fccdbd1359
-- Include max/min/last over time

-- load 10s
-- data{type="numbers"} 2 0 3
-- data{type="some_nan"} 2 0 NaN
-- data{type="some_nan2"} 2 NaN 1
-- data{type="some_nan3"} NaN 0 1
-- data{type="only_nan"} NaN NaN NaN
create table data (ts timestamp(3) time index, val double, ty string primary key);

insert into data values
(0, 2::double, 'numbers'),
(10000, 0::double, 'numbers'),
(20000, 3::double, 'numbers'),
(0, 2::double, 'some_nan'),
(10000, 0::double, 'some_nan'),
(20000, 'NaN'::double, 'some_nan'),
(0, 2::double, 'some_nan2'),
(10000, 'NaN'::double, 'some_nan2'),
(20000, 1::double, 'some_nan2'),
(0, 'NaN'::double, 'some_nan3'),
(10000, 0::double, 'some_nan3'),
(20000, 1::double, 'some_nan3'),
(0, 'NaN'::double, 'only_nan'),
(10000, 'NaN'::double, 'only_nan'),
(20000, 'NaN'::double, 'only_nan');

-- eval instant at 1m min_over_time(data[1m])
-- {type="numbers"} 0
-- {type="some_nan"} 0
-- {type="some_nan2"} 1
-- {type="some_nan3"} 0
-- {type="only_nan"} NaN
-- tql eval (60, 60, '1s') min_over_time(data[1m]);

-- eval instant at 1m max_over_time(data[1m])
-- {type="numbers"} 3
-- {type="some_nan"} 2
-- {type="some_nan2"} 2
-- {type="some_nan3"} 1
-- {type="only_nan"} NaN
-- tql eval (60, 60, '1s') max_over_time(data[1m]);

-- eval instant at 1m last_over_time(data[1m])
-- data{type="numbers"} 3
-- data{type="some_nan"} NaN
-- data{type="some_nan2"} 1
-- data{type="some_nan3"} 1
-- data{type="only_nan"} NaN
-- tql eval (60, 60, '1s') last_over_time(data[1m]);

drop table data;

0 comments on commit fa0a032

Please sign in to comment.