homework-jianmu/tests/script/tsim/parser/columnValue_json.sim

221 lines
6.3 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 ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: json
print ========== json
sql create table mt_json (ts timestamp, c varchar(50)) tags(tagname json)
## case 00: static create table for test tag values
sql create table st_json_0 using mt_json tags(NULL)
sql show tags from st_json_0
if $data05 != NULL then
return -1
endi
sql create table st_json_1 using mt_json tags(NULL)
sql show tags from st_json_1
if $data05 != NULL then
return -1
endi
sql create table st_json_2 using mt_json tags('NULL')
sql show tags from st_json_2
if $data05 != NULL then
return -1
endi
sql create table st_json_3 using mt_json tags('NULL')
sql show tags from st_json_3
if $data05 != NULL then
return -1
endi
sql create table st_json_4 using mt_json tags("NULL")
sql show tags from st_json_4
if $data05 != NULL then
return -1
endi
sql create table st_json_5 using mt_json tags("NULL")
sql show tags from st_json_5
if $data05 != NULL then
return -1
endi
sql create table st_json_6 using mt_json tags("")
sql show tags from st_json_6
if $data05 != NULL then
return -1
endi
sql create table st_json_7 using mt_json tags(" ")
sql show tags from st_json_7
if $data05 != NULL then
return -1
endi
sql create table st_json_8 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"}")
sql show tags from st_json_8
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
## case 01: insert values for test column values
## case 02: dynamic create table for test tag values
sql insert into st_json_100 using mt_json tags(NULL) values(now,NULL)
sql show tags from st_json_100
if $data05 != NULL then
return -1
endi
sql select * from st_json_100
if $data01 != NULL then
return -1
endi
sql insert into st_json_101 using mt_json tags(NULL) values(now,NULL)
sql show tags from st_json_101
if $data05 != NULL then
return -1
endi
sql select * from st_json_101
if $data01 != NULL then
return -1
endi
sql insert into st_json_102 using mt_json tags('NULL') values(now,'NULL')
sql show tags from st_json_102
if $data05 != NULL then
return -1
endi
sql select * from st_json_102
if $data01 != NULL then
return -1
endi
sql insert into st_json_103 using mt_json tags('NULL') values(now,'NULL')
sql show tags from st_json_103
if $data05 != NULL then
return -1
endi
sql select * from st_json_103
if $data01 != NULL then
return -1
endi
sql insert into st_json_104 using mt_json tags("NULL") values(now,"NULL")
sql show tags from st_json_104
if $data05 != NULL then
return -1
endi
sql select * from st_json_104
if $data01 != NULL then
return -1
endi
sql insert into st_json_105 using mt_json tags("NULL") values(now,"NULL")
sql show tags from st_json_105
if $data05 != NULL then
return -1
endi
sql select * from st_json_105
if $data01 != NULL then
return -1
endi
sql insert into st_json_106 using mt_json tags("") values(now,"vc")
sql show tags from st_json_106
if $data05 != NULL then
return -1
endi
sql select * from st_json_106
if $data01 != vc then
return -1
endi
sql insert into st_json_107 using mt_json tags(" ") values(now,"vc")
sql show tags from st_json_107
if $data05 != NULL then
return -1
endi
sql select * from st_json_107
if $data01 != vc then
return -1
endi
sql insert into st_json_108 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"} ") values(now,"vc")
sql show tags from st_json_108
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
sql select * from st_json_108
if $data01 != vc then
return -1
endi
## case 03: alter tag values
sql alter table st_json_100 set tag tagname=NULL
sql show tags from st_json_100
if $data05 != NULL then
return -1
endi
sql alter table st_json_101 set tag tagname=NULL
sql show tags from st_json_101
if $data05 != NULL then
return -1
endi
sql alter table st_json_102 set tag tagname='NULL'
sql show tags from st_json_102
if $data05 != NULL then
return -1
endi
sql alter table st_json_103 set tag tagname='NULL'
sql show tags from st_json_103
if $data05 != NULL then
return -1
endi
sql alter table st_json_104 set tag tagname="NULL"
sql show tags from st_json_104
if $data05 != NULL then
return -1
endi
sql alter table st_json_105 set tag tagname="NULL"
sql show tags from st_json_105
if $data05 != NULL then
return -1
endi
sql alter table st_json_106 set tag tagname=""
sql show tags from st_json_106
if $data05 != NULL then
return -1
endi
sql alter table st_json_107 set tag tagname=" "
sql show tags from st_json_107
if $data05 != NULL then
return -1
endi
sql alter table st_json_108 set tag tagname="{\"k1\":\"v1\",\"k2\":\"v2\"}"
sql show tags from st_json_108
if $data05 != {"k1":"v1","k2":"v2"} then
return -1
endi
# case 04: illegal input
sql_error create table st_json_206 using mt_json tags(+0123)
sql_error create table st_json_207 using mt_json tags(-01.23)
sql_error create table st_json_208 using mt_json tags(+0x01)
sql_error create table st_json_209 using mt_json tags(-0b01)
sql_error create table st_json_2010 using mt_json tags(-0.1e-10)
sql_error create table st_json_2011 using mt_json tags(+0.1E+2)
sql_error create table st_json_2012 using mt_json tags(tRue)
sql_error create table st_json_2013 using mt_json tags(FalsE)
sql_error create table st_json_2014 using mt_json tags(noW)
sql_error create table st_json_2015 using mt_json tags(toDay)
sql_error insert into st_json_206 using mt_json tags(+0123) values(now, NULL);
sql_error insert into st_json_207 using mt_json tags(-01.23) values(now, NULL);
sql_error insert into st_json_208 using mt_json tags(+0x01) values(now, NULL);
sql_error insert into st_json_209 using mt_json tags(-0b01) values(now, NULL);
sql_error insert into st_json_2010 using mt_json tags(-0.1e-10) values(now, NULL);
sql_error insert into st_json_2011 using mt_json tags(+0.1E+2) values(now, NULL);
sql_error insert into st_json_2012 using mt_json tags(tRue) values(now, NULL);
sql_error insert into st_json_2013 using mt_json tags(FalsE) values(now, NULL);
sql_error insert into st_json_2014 using mt_json tags(noW) values(now, NULL);
sql_error insert into st_json_2015 using mt_json tags(toDay) values(now, NULL);
system sh/exec.sh -n dnode1 -s stop -x SIGINT