tdSql.query("select jtag from jsons1 where jtag->'k1'=''")
tdSql.checkRows(1)
tdSql.query("select jtag from jsons1 where jtag->'k2'=true")
tdSql.checkRows(1)
tdSql.query("select jtag from jsons1 where jtag is null")
tdSql.checkRows(5)
tdSql.query("select jtag from jsons1 where jtag is not null")
tdSql.checkRows(5)
tdSql.query("select * from jsons1 where jtag->'location' is not null")
tdSql.checkRows(3)
tdSql.query("select tbname,jtag from jsons1 where jtag->'location' is null")
tdSql.checkRows(7)
tdSql.query("select * from jsons1 where jtag->'num' is not null")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'location'='null'")
tdSql.checkRows(0)
tdSql.error("select * from jsons1 where jtag->'num'='null'")
# test distinct
tdSql.query("select distinct jtag from jsons1")
tdSql.checkRows(6)
tdSql.query("select distinct jtag->'location' from jsons1")
tdSql.checkRows(2)
# test chinese
tdSql.execute("CREATE TABLE if not exists jsons1_11 using jsons1 tags('{\"k1\":\"中国\",\"k5\":\"是是是\"}')")
tdSql.query("select tbname,jtag from jsons1 where jtag->'k1' match '中'")
tdSql.checkRows(1)
tdSql.query("select tbname,jtag from jsons1 where jtag->'k1'='中国'")
tdSql.checkRows(1)
#test dumplicate key with normal colomn
tdSql.execute("INSERT INTO jsons1_12 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"dataStr\":\"是是是\"}') values(now, 4, \"你就会\")")
tdSql.query("select *,tbname,jtag from jsons1 where jtag->'dataStr' match '是'")
tdSql.checkRows(1)
tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt'")
tdSql.checkRows(1)
# tdSql.query("select * from jsons1 where jtag->'num' is not null or jtag?'class' and jtag?'databool'")
# tdSql.checkRows(0)
# tdSql.query("select * from jsons1 where jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%'")
# tdSql.query("select * from jsons1 where datastr like '你就会' and ( jtag->'num' is not null or jtag?'class' and jtag?'databool' )")
tdSql.error("select * from jsons1 where datastr like '你就会' or jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%' ")
# tdSql.query("select * from jsons1 where datastr like '你就会' and (jtag->'num' is not null or jtag?'class' and jtag?'databool' and jtag->'k1' match '中' or jtag->'location' in ('beijing') and jtag->'location' like 'bei%' )")
# tdSql.checkRows(0)
tdSql.error("select *,tbname,jtag from jsons1 where dataBool=true")
# test error
tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags(3333)")
tdSql.execute("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"1loc\":\"fff\",\";id\":5}')")
tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"。loc\":\"fff\",\"fsd\":5}')")
tdSql.error("CREATE TABLE if not exists jsons1_13 using jsons1 tags('{\"试试\":\"fff\",\";id\":5}')")
tdSql.error("insert into jsons1_13 using jsons1 tags(3)")
# test query normal column
tdSql.execute("create stable if not exists jsons3(ts timestamp, dataInt3 int(100), dataBool3 bool, dataStr3 nchar(50)) tags(jtag3 json)")
tdSql.execute("create table jsons3_2 using jsons3 tags('{\"t\":true,\"t123\":123,\"\":\"true\"}')")
tdSql.execute("create table jsons3_3 using jsons3 tags('{\"t\":true,\"t123\":456,\"k1\":true}')")
tdSql.execute("insert into jsons3_3 values(now, 4, true, 'test')")
tdSql.execute("insert into jsons3_4 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":false,\"s\":null}') values(now, 5, true, 'test')")
tdSql.query("select * from jsons3 where jtag3->'k1'=true")
tdSql.checkRows(1)
tdSql.error("select jtag3->k1 from jsons3 ")
tdSql.error("select jtag3 from jsons3 where jtag3->'k1'")
tdSql.error("select jtag3 from jsons3 where jtag3?'k1'=true")
tdSql.error("select jtag3?'k1' from jsons3;")
tdSql.error("select jtag3?'k1'=true from jsons3;")
tdSql.error("select jtag3->'k1'=true from jsons3;")
tdSql.error("insert into jsons3_5 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":1,\"s\":null}') values(now, 5, true, 'test')")
tdSql.execute("insert into jsons3_5 using jsons3 tags('{\"t\":true,\"t123\":012,\"k1\":null,\"s\":null}') values(now, 5, true, 'test')")
tdSql.execute("insert into jsons3_6 using jsons3 tags('{\"t\":true,\"t123\":789,\"k1\":false,\"s\":null}') values(now, 5, true, 'test')")
# tdSql.execute("select distinct jtag3 from jsons3 where jtag3->'t123'=12 or jtag3?'k1'")
# tdSql.checkRows(3)
tdSql.execute("INSERT INTO jsons1_14 using jsons1 tags('{\"tbname\":\"tt\",\"location\":\"tianjing\",\"dataStr\":\"是是是\"}') values(now,5, \"你就会\")")
# tdSql.execute("select ts,dataint3,jtag->tbname from jsons1 where dataint>=1 and jtag->'location' in ('tianjing','123') and jtag?'tbname'")
# tdSql.checkRows(1)
# tdSql.checkData(0, 2, 'tt')
# query normal column and tag column
tdSql.query("select jtag3->'',dataint3 from jsons3")
tdSql.checkRows(4)
# query child table
tdSql.error("select * from jsons3_2 where jtag3->'k1'=true;")