Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7a7d49d3
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看板
提交
7a7d49d3
编写于
12月 01, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable different value type of the same key in json
上级
d62844be
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
10 deletion
+38
-10
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-0
src/query/src/qFilter.c
src/query/src/qFilter.c
+28
-0
src/util/src/tcompare.c
src/util/src/tcompare.c
+2
-0
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+5
-10
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
7a7d49d3
...
...
@@ -4716,6 +4716,7 @@ static int32_t validateJsonTagExpr(tSqlExpr* pExpr, char* msgBuf) {
const
char
*
msg1
=
"not support json tag column filter"
;
const
char
*
msg2
=
"tag json key is invalidate"
;
const
char
*
msg3
=
"tag json key must be string"
;
const
char
*
msg4
=
"in operation not support in tag json"
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
...
...
@@ -4726,6 +4727,8 @@ static int32_t validateJsonTagExpr(tSqlExpr* pExpr, char* msgBuf) {
if
(
pRight
!=
NULL
&&
(
pRight
->
value
.
nLen
>
TSDB_MAX_JSON_KEY_LEN
||
pRight
->
value
.
nLen
<=
0
))
return
invalidOperationMsg
(
msgBuf
,
msg2
);
}
else
if
(
pExpr
->
tokenId
==
TK_IN
){
return
invalidOperationMsg
(
msgBuf
,
msg4
);
}
else
{
if
(
pLeft
!=
NULL
&&
pLeft
->
tokenId
==
TK_ID
&&
pExpr
->
tokenId
!=
TK_ISNULL
&&
pExpr
->
tokenId
!=
TK_NOTNULL
)
{
return
invalidOperationMsg
(
msgBuf
,
msg1
);
...
...
src/query/src/qFilter.c
浏览文件 @
7a7d49d3
...
...
@@ -234,6 +234,8 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
comparFn
=
19
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
20
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
9
;
}
else
if
(
optr
==
TSDB_RELATION_QUESTION
)
{
comparFn
=
21
;
}
else
{
...
...
@@ -3061,6 +3063,19 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
newColData
,
newValData
);
tfree
(
newColData
);
}
}
else
if
(
info
->
cunits
[
uidx
].
optr
==
TSDB_RELATION_LIKE
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
tVariant
*
val
=
info
->
cunits
[
uidx
].
valData
;
char
*
newValData
=
calloc
(
val
->
nLen
+
VARSTR_HEADER_SIZE
,
1
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
realData
,
newValData
);
tfree
(
newValData
);
}
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
info
->
cunits
[
uidx
].
func
],
info
->
cunits
[
uidx
].
optr
,
colData
,
info
->
cunits
[
uidx
].
valData
);
}
...
...
@@ -3138,6 +3153,19 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
newColData
,
newValData
);
tfree
(
newColData
);
}
}
else
if
(
cunit
->
optr
==
TSDB_RELATION_LIKE
){
uint8_t
jsonType
=
*
(
char
*
)
colData
;
char
*
realData
=
colData
+
CHAR_BYTES
;
if
(
jsonType
!=
TSDB_DATA_TYPE_NCHAR
){
(
*
p
)[
i
]
=
false
;
}
else
{
tVariant
*
val
=
cunit
->
valData
;
char
*
newValData
=
calloc
(
val
->
nLen
+
VARSTR_HEADER_SIZE
,
1
);
memcpy
(
varDataVal
(
newValData
),
val
->
pz
,
val
->
nLen
);
varDataSetLen
(
newValData
,
val
->
nLen
);
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
realData
,
newValData
);
tfree
(
newValData
);
}
}
else
{
(
*
p
)[
i
]
=
filterDoCompare
(
gDataCompare
[
cunit
->
func
],
cunit
->
optr
,
colData
,
cunit
->
valData
);
}
...
...
src/util/src/tcompare.c
浏览文件 @
7a7d49d3
...
...
@@ -540,6 +540,8 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
comparFn
=
compareStrRegexCompMatch
;
}
else
if
(
optr
==
TSDB_RELATION_NMATCH
)
{
comparFn
=
compareStrRegexCompNMatch
;
}
else
if
(
optr
==
TSDB_RELATION_LIKE
)
{
/* wildcard query using like operator */
comparFn
=
compareWStrPatternComp
;
}
else
if
(
optr
==
TSDB_RELATION_QUESTION
)
{
comparFn
=
compareStrContainJson
;
}
else
{
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
7a7d49d3
...
...
@@ -142,20 +142,14 @@ 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
)
tdSql
.
error
(
"select * from db_json_tag_test.jsons1 where jtag->'num' like '5%'"
)
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'num' like '5%'"
)
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->'location' in ('beijing')"
)
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
)
# test where condition match
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'location' match 'jin$'"
)
tdSql
.
checkRows
(
0
)
...
...
@@ -166,7 +160,8 @@ class TDTestCase:
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where datastr match 'json' and jtag->'location' match 'jin'"
)
tdSql
.
checkRows
(
2
)
tdSql
.
error
(
"select * from db_json_tag_test.jsons1 where jtag->'num' match '5'"
)
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'num' match '5'"
)
tdSql
.
checkRows
(
0
)
# test json string parse
tdSql
.
error
(
"CREATE TABLE if not exists db_json_tag_test.jsons1_5 using db_json_tag_test.jsons1 tags('efwewf')"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录