homework-jianmu/tests/script/tsim/scalar/tsConvert.sim

128 lines
2.8 KiB
Plaintext

system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ======== step1
sql drop database if exists db1;
sql create database db1;
sql use db1;
sql create stable st1 (ts timestamp, f1 int, f2 binary(30)) tags(t1 int, t2 binary(30));
sql create table tb1 using st1 tags(1, '1');
sql insert into tb1 values ('2022-07-10 16:31:00', 1, '1');
sql insert into tb1 values ('2022-07-10 16:32:00', 2, '2');
sql insert into tb1 values ('2022-07-10 16:33:00', 3, '3');
sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4');
sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <='2022-11-3 23:59:59' ) t where td >12;
if $rows != 4 then
return -1
endi
if $data00 != @22-07-10 16:31:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data30 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where ts > '2022-07-10 16:32:00';
if $rows != 2 then
return -1
endi
if $data00 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where ts + 1 > '2022-07-10 16:32:00';
if $rows != 3 then
return -1
endi
if $data00 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where '2022-07-10 16:32:00' > timestamp '2022-07-10 16:31:59';
if $rows != 4 then
return -1
endi
if $data00 != @22-07-10 16:31:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data30 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select case f1 when '1' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case ts when '2022-07-10 16:31:00' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case '2022-07-10 16:31:00' when ts then 1 when 2022 then '2' else 3 end from tb1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 3 then
return -1
endi
if $data20 != 3 then
return -1
endi
if $data30 != 3 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT