Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
698f954b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
698f954b
编写于
9月 30, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> add tag?'key' in where logic
上级
e01c569e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
7 deletion
+21
-7
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+4
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+1
-2
src/util/src/tarray.c
src/util/src/tarray.c
+2
-2
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+12
-0
未找到文件。
src/client/src/tscLocal.c
浏览文件 @
698f954b
...
...
@@ -89,7 +89,10 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
STR_WITH_MAXSIZE_TO_VARSTR
(
dst
,
type
,
pField
->
bytes
);
int32_t
bytes
=
pSchema
[
i
].
bytes
;
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
||
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_JSON
&&
JSON_TYPE_BINARY
)){
bytes
-=
VARSTR_HEADER_SIZE
;
}
else
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
||
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_JSON
&&
JSON_TYPE_NCHAR
))
{
bytes
-=
VARSTR_HEADER_SIZE
;
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
...
src/client/src/tscUtil.c
浏览文件 @
698f954b
...
...
@@ -5325,7 +5325,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
char
tagVal
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
int32_t
outLen
=
0
;
if
(
JSON_TYPE_BINARY
){
strncpy
(
tagVal
,
item
->
string
,
strlen
(
item
->
string
));
strncpy
(
varDataVal
(
tagVal
)
,
item
->
string
,
strlen
(
item
->
string
));
outLen
=
strlen
(
item
->
string
);
}
else
if
(
JSON_TYPE_NCHAR
){
if
(
!
taosMbsToUcs4
(
item
->
string
,
strlen
(
item
->
string
),
varDataVal
(
tagVal
),
TSDB_MAX_TAGS_LEN
-
VARSTR_HEADER_SIZE
,
&
outLen
))
{
...
...
@@ -5344,7 +5344,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
*
tagVal
=
jsonType2DbType
(
0
,
item
->
type
);
// type
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
if
(
JSON_TYPE_BINARY
){
strncpy
(
tagVal
,
item
->
valuestring
,
strlen
(
item
->
valuestring
));
strncpy
(
varDataVal
(
tagData
)
,
item
->
valuestring
,
strlen
(
item
->
valuestring
));
outLen
=
strlen
(
item
->
valuestring
);
}
else
if
(
JSON_TYPE_NCHAR
)
{
if
(
!
taosMbsToUcs4
(
item
->
valuestring
,
strlen
(
item
->
valuestring
),
varDataVal
(
tagData
),
...
...
src/query/src/qExecutor.c
浏览文件 @
698f954b
...
...
@@ -7181,7 +7181,6 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
type
=
pExprInfo
[
j
].
base
.
resType
;
bytes
=
pExprInfo
[
j
].
base
.
resBytes
;
char
*
tagJsonElementData
=
NULL
;
dst
=
pColInfo
->
pData
+
count
*
pExprInfo
[
j
].
base
.
resBytes
;
if
(
pExprInfo
[
j
].
base
.
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
data
=
tsdbGetTableName
(
item
->
pTable
);
...
...
@@ -7189,7 +7188,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
if
(
type
==
TSDB_DATA_TYPE_JSON
){
data
=
tsdbGetTableTagVal
(
item
->
pTable
,
pExprInfo
[
j
].
base
.
colInfo
.
colId
,
type
,
bytes
);
if
(
pExprInfo
[
j
].
base
.
numOfParams
>
0
){
// tag-> operation
tagJsonElementData
=
calloc
(
bytes
,
1
);
char
*
tagJsonElementData
=
calloc
(
bytes
,
1
);
findTagValue
(
item
->
pTable
,
pExprInfo
[
j
].
base
.
param
[
0
].
pz
,
pExprInfo
[
j
].
base
.
param
[
0
].
nLen
,
tagJsonElementData
,
bytes
);
*
dst
=
SELECT_ELEMENT_JSON_TAG
;
// select tag->element
dst
++
;
...
...
src/util/src/tarray.c
浏览文件 @
698f954b
...
...
@@ -281,8 +281,8 @@ void taosArrayClear(SArray* pArray) {
void
*
taosArrayDestroy
(
SArray
*
pArray
)
{
if
(
pArray
)
{
free
(
pArray
->
pData
);
free
(
pArray
);
t
free
(
pArray
->
pData
);
t
free
(
pArray
);
}
return
NULL
;
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
698f954b
...
...
@@ -142,6 +142,18 @@ class TDTestCase:
tdSql
.
query
(
"select *,tbname from db_json_tag_test.jsons1 where (jtag->'location' like 'bei%' or jtag->'num'=34) and jtag->'class'=55"
)
tdSql
.
checkRows
(
0
)
# test where condition in
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'location' in ('beijing')"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'num' in (5,34)"
)
tdSql
.
checkRows
(
2
)
tdSql
.
error
(
"select * from db_json_tag_test.jsons1 where jtag->'num' in ('5',34)"
)
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'location' in ('shanghai') and jtag->'class'=55"
)
tdSql
.
checkRows
(
1
)
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录