Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c937313e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c937313e
编写于
6月 02, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add json test case
上级
7196bb13
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
49 deletion
+49
-49
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+1
-1
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+47
-47
未找到文件。
source/client/src/clientImpl.c
浏览文件 @
c937313e
...
...
@@ -1175,7 +1175,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TD_TAG_JSON
)
{
char
*
jsonString
=
parseTagDatatoJson
(
jsonInnerData
);
char
*
jsonString
=
parseTagDatatoJson
(
pStart
);
STR_TO_VARSTR
(
dst
,
jsonString
);
taosMemoryFree
(
jsonString
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
...
...
source/common/src/tmsg.c
浏览文件 @
c937313e
...
...
@@ -34,7 +34,7 @@ int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
return
-
1
;
}
pIter
->
totalLen
=
hton
l
(
pMsg
->
length
);
pIter
->
totalLen
=
ntoh
l
(
pMsg
->
length
);
ASSERT
(
pIter
->
totalLen
>
0
);
pIter
->
len
=
0
;
pIter
->
pMsg
=
pMsg
;
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
c937313e
...
...
@@ -48,8 +48,8 @@ class TDTestCase:
# test duplicate key using the first one. elimate empty key
tdSql
.
execute
(
"CREATE TABLE if not exists jsons1_8 using jsons1 tags('{
\"
tag1
\"
:null,
\"
tag1
\"
:true,
\"
tag1
\"
:45,
\"
1tag$
\"
:2,
\"
\"
:90,
\"\"
:32}')"
)
#
tdSql.query("select jtag from jsons1_8")
#tdSql.checkData(0, 0, '{"tag1":null,"1tag$":2," ":90
}')
tdSql
.
query
(
"select jtag from jsons1_8"
)
tdSql
.
checkData
(
0
,
0
,
'{" ":90,"1tag$":2,"tag1":null
}'
)
# test empty json string, save as jtag is NULL
tdSql
.
execute
(
"insert into jsons1_9 using jsons1 tags('
\t
') values (1591062328000, 24, NULL, '你就会', '2sdw')"
)
...
...
@@ -95,8 +95,8 @@ class TDTestCase:
tdSql
.
error
(
"ALTER TABLE jsons1 MODIFY TAG jtag nchar(128)"
)
#
tdSql
.
execute
(
"ALTER TABLE jsons1_1 SET TAG jtag='{
\"
tag1
\"
:
\"
femail
\"
,
\"
tag2
\"
:35,
\"
tag3
\"
:true}'"
)
#
tdSql.query("select jtag from jsons1_1")
#
tdSql.checkData(0, 0, '{"tag1":"femail","tag2":35,"tag3":true}')
tdSql
.
query
(
"select jtag from jsons1_1"
)
tdSql
.
checkData
(
0
,
0
,
'{"tag1":"femail","tag2":35,"tag3":true}'
)
tdSql
.
execute
(
"ALTER TABLE jsons1 rename TAG jtag jtag_new"
)
tdSql
.
execute
(
"ALTER TABLE jsons1 rename TAG jtag_new jtag"
)
...
...
@@ -106,18 +106,18 @@ class TDTestCase:
#
# print("============== STEP 3 ===== query table")
# # test error syntax
#
tdSql.error("select * from jsons1 where jtag->tag1='beijing'")
#
tdSql.error("select * from jsons1 where jtag->'location'")
#
tdSql.error("select * from jsons1 where jtag->''")
#
tdSql.error("select * from jsons1 where jtag->''=9")
#
tdSql.error("select -> from jsons1")
#
tdSql.error("select * from jsons1 where contains")
#
tdSql.error("select * from jsons1 where jtag->")
#
tdSql.error("select jtag->location from jsons1")
#
tdSql.error("select jtag contains location from jsons1")
#
tdSql.error("select * from jsons1 where jtag contains location")
#
tdSql.error("select * from jsons1 where jtag contains''")
#
tdSql.error("select * from jsons1 where jtag contains 'location'='beijing'")
tdSql
.
error
(
"select * from jsons1 where jtag->tag1='beijing'"
)
#tdSql.error("select * from jsons1 where jtag->'location'")
#tdSql.error("select * from jsons1 where jtag->''")
#tdSql.error("select * from jsons1 where jtag->''=9")
tdSql
.
error
(
"select -> from jsons1"
)
tdSql
.
error
(
"select * from jsons1 where contains"
)
tdSql
.
error
(
"select * from jsons1 where jtag->"
)
tdSql
.
error
(
"select jtag->location from jsons1"
)
tdSql
.
error
(
"select jtag contains location from jsons1"
)
tdSql
.
error
(
"select * from jsons1 where jtag contains location"
)
tdSql
.
error
(
"select * from jsons1 where jtag contains''"
)
tdSql
.
error
(
"select * from jsons1 where jtag contains 'location'='beijing'"
)
#
# # test function error
# tdSql.error("select avg(jtag->'tag1') from jsons1")
...
...
@@ -128,47 +128,47 @@ class TDTestCase:
# tdSql.error("select ceil(jtag) from jsons1")
#
# # test select normal column
#
tdSql.query("select dataint from jsons1")
#
tdSql.checkRows(9)
#
tdSql.checkData(1, 0, 1)
tdSql
.
query
(
"select dataint from jsons1"
)
tdSql
.
checkRows
(
9
)
tdSql
.
checkData
(
1
,
0
,
1
)
# test select json tag
#
tdSql.query("select * from jsons1")
# tdSql.checkRows(8
)
#
tdSql.query("select jtag from jsons1")
# tdSql.checkRows(7
)
tdSql
.
query
(
"select * from jsons1"
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select jtag from jsons1"
)
tdSql
.
checkRows
(
13
)
# 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(8)
# test jtag is NULL
#
tdSql.query("select jtag from jsons1_9")
#
tdSql.checkData(0, 0, None)
tdSql
.
query
(
"select jtag from jsons1_9"
)
tdSql
.
checkData
(
0
,
0
,
None
)
# # test select json tag->'key', value is string
#
tdSql.query("select jtag->'tag1' from jsons1_1")
#
tdSql.checkData(0, 0, '"femail"')
#
tdSql.query("select jtag->'tag2' from jsons1_6")
#
tdSql.checkData(0, 0, '""')
#
#
test select json tag->'key', value is int
#
tdSql.query("select jtag->'tag2' from jsons1_1")
# tdSql.checkData(0, 0, 35
)
#
#
test select json tag->'key', value is bool
#
tdSql.query("select jtag->'tag3' from jsons1_1")
#
tdSql.checkData(0, 0, "true")
#
#
test select json tag->'key', value is null
#
tdSql.query("select jtag->'tag1' from jsons1_4")
#
tdSql.checkData(0, 0, "null")
#
#
test select json tag->'key', value is double
#
tdSql.query("select jtag->'tag1' from jsons1_5")
#
tdSql.checkData(0, 0, "1.232000000")
#
#
test select json tag->'key', key is not exist
#
tdSql.query("select jtag->'tag10' from jsons1_4")
#
tdSql.checkData(0, 0, None)
#
#
tdSql.query("select jtag->'tag1' from jsons1")
#
tdSql.checkRows(13)
tdSql
.
query
(
"select jtag->'tag1' from jsons1_1"
)
tdSql
.
checkData
(
0
,
0
,
'"femail"'
)
tdSql
.
query
(
"select jtag->'tag2' from jsons1_6"
)
tdSql
.
checkData
(
0
,
0
,
'""'
)
# test select json tag->'key', value is int
tdSql
.
query
(
"select jtag->'tag2' from jsons1_1"
)
tdSql
.
checkData
(
0
,
0
,
"35.000000000"
)
# test select json tag->'key', value is bool
tdSql
.
query
(
"select jtag->'tag3' from jsons1_1"
)
tdSql
.
checkData
(
0
,
0
,
"true"
)
# test select json tag->'key', value is null
tdSql
.
query
(
"select jtag->'tag1' from jsons1_4"
)
tdSql
.
checkData
(
0
,
0
,
"null"
)
# test select json tag->'key', value is double
tdSql
.
query
(
"select jtag->'tag1' from jsons1_5"
)
tdSql
.
checkData
(
0
,
0
,
"1.232000000"
)
# test select json tag->'key', key is not exist
tdSql
.
query
(
"select jtag->'tag10' from jsons1_4"
)
tdSql
.
checkData
(
0
,
0
,
None
)
#
tdSql
.
query
(
"select jtag->'tag1' from jsons1"
)
tdSql
.
checkRows
(
13
)
# test header name
res
=
tdSql
.
getColNameList
(
"select jtag->'tag1' from jsons1"
)
cname_list
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录