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 * 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.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1' match '收到'")
tdSql.query("select * from jsons1 where jtag->'location'='null'")
tdSql.checkRows(1)
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'num'='null'")
tdSql.checkRows(0)
# test distinct
# test distinct
tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')")
tdSql.query("select distinct jtag->'tag1' from jsons1")
tdSql.checkRows(8)
tdSql.query("select distinct jtag from jsons1")
tdSql.query("select distinct jtag from jsons1")
tdSql.checkRows(7)
tdSql.checkRows(9)
tdSql.query("select distinct jtag->'location' from jsons1")
tdSql.checkRows(3)
# test chinese
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
#test dumplicate key with normal colomn
tdSql.execute("INSERT INTO jsons1_12 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"dataStr\":\"是是是\"}') values(1591060828000, 4, false, \"你就会\")")
tdSql.execute("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"是是是\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")")
tdSql.query("select *,tbname,jtag from jsons1 where jtag->'datastr' match '是' and datastr match 'js'")
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.checkRows(1)
tdSql.query("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'")
tdSql.query("select *,tbname,jtag from jsons1 where dataBool=true")
tdSql.checkRows(0)
tdSql.checkRows(2)
# test error
# test join
# test join
tdSql.query("select 'sss',33,a.jtag->'loc' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'loc'=b.jtag->'loc'")
tdSql.execute("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)")
tdSql.execute("insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2')")
tdSql.execute("insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')")
tdSql.execute("create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)")
tdSql.execute("insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3')")
tdSql.execute("insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')")
tdSql.query("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'")
tdSql.checkData(0,0,"sss")
tdSql.checkData(0,0,"sss")
tdSql.checkData(0,2,"\"fff\"")
tdSql.checkData(0,2,"true")
res=tdSql.getColNameList("select 'sss',33,a.jtag->'loc' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'loc'=b.jtag->'loc'")
res=tdSql.getColNameList("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'")
cname_list=[]
cname_list=[]
cname_list.append("sss")
cname_list.append("sss")
cname_list.append("33")
cname_list.append("33")
cname_list.append("a.jtag->'loc'")
cname_list.append("a.jtag->'tag3'")
tdSql.checkColNameList(res,cname_list)
tdSql.checkColNameList(res,cname_list)
# test group by & order by string
# test group by & order by string
tdSql.query("select avg(dataint),count(*) from jsons1 group by jtag->'location' order by jtag->'location' desc")
tdSql.query("select avg(dataint),count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")