Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
186c2694
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看板
提交
186c2694
编写于
11月 26, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the output format of json string; add ""
上级
10036749
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
6 deletion
+14
-6
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+10
-2
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+4
-4
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
186c2694
...
...
@@ -763,19 +763,27 @@ static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bo
char
*
dst
=
pRes
->
buffer
[
i
]
+
k
*
pInfo
->
field
.
bytes
;
char
type
=
*
p
;
char
*
realData
=
p
+
CHAR_BYTES
;
if
(
type
==
TSDB_DATA_TYPE_
NCHAR
&&
isNull
(
realData
,
TSDB_DATA_TYPE_NCHAR
))
{
if
(
type
==
TSDB_DATA_TYPE_
JSON
&&
isNull
(
realData
,
TSDB_DATA_TYPE_JSON
))
{
memcpy
(
dst
,
realData
,
varDataTLen
(
realData
));
}
else
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
assert
(
*
(
uint32_t
*
)
varDataVal
(
realData
)
==
TSDB_DATA_JSON_null
);
// json null value
assert
(
varDataLen
(
realData
)
==
INT_BYTES
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
"null"
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
type
==
TSDB_DATA_TYPE_
NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_
JSON
)
{
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
varDataVal
(
dst
));
varDataSetLen
(
dst
,
length
);
if
(
length
==
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
p
);
}
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
*
(
char
*
)
varDataVal
(
dst
)
=
'\"'
;
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
POINTER_SHIFT
(
varDataVal
(
dst
),
CHAR_BYTES
));
*
(
char
*
)(
POINTER_SHIFT
(
varDataVal
(
dst
),
length
+
CHAR_BYTES
))
=
'\"'
;
varDataSetLen
(
dst
,
length
+
CHAR_BYTES
*
2
);
if
(
length
==
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
p
);
}
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
jsonVd
=
*
(
double
*
)(
realData
);
sprintf
(
varDataVal
(
dst
),
"%.9lf"
,
jsonVd
);
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
186c2694
...
...
@@ -69,7 +69,7 @@ class TDTestCase:
# test select condition
tdSql
.
query
(
"select jtag->'location' from db_json_tag_test.jsons1_2"
)
tdSql
.
checkData
(
0
,
0
,
"
beijing
"
)
tdSql
.
checkData
(
0
,
0
,
"
\"
beijing
\"
"
)
tdSql
.
query
(
"select jtag->'location' from db_json_tag_test.jsons1"
)
tdSql
.
checkRows
(
4
)
...
...
@@ -105,7 +105,7 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select jtag->'sex' from db_json_tag_test.jsons1 where jtag?'sex' or jtag?'num'"
)
tdSql
.
checkData
(
0
,
0
,
"
femail
"
)
tdSql
.
checkData
(
0
,
0
,
"
\"
femail
\"
"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select *,tbname from db_json_tag_test.jsons1 where jtag->'location'='beijing'"
)
...
...
@@ -265,13 +265,13 @@ class TDTestCase:
tdSql
.
execute
(
"insert into db_json_tag_test.jsons2_1 values('2020-04-18 15:00:00.000', 1, false, 'json1')"
)
tdSql
.
query
(
"select 'sss',33,a.jtag->'loc' from db_json_tag_test.jsons2 a,db_json_tag_test.jsons3 b where a.ts=b.ts and a.jtag->'loc'=b.jtag->'loc'"
)
tdSql
.
checkData
(
0
,
0
,
"sss"
)
tdSql
.
checkData
(
0
,
2
,
"
fff
"
)
tdSql
.
checkData
(
0
,
2
,
"
\"
fff
\"
"
)
# test group by & order by string
tdSql
.
query
(
"select avg(dataint),count(*) from db_json_tag_test.jsons1 group by jtag->'location' order by jtag->'location' desc"
)
tdSql
.
checkData
(
1
,
0
,
2.5
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
1
,
2
,
"
beijing
"
)
tdSql
.
checkData
(
1
,
2
,
"
\"
beijing
\"
"
)
tdSql
.
checkData
(
2
,
2
,
None
)
# test group by & order by int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录