Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
da60fb5e
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看板
提交
da60fb5e
编写于
10月 18, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> support null true false for json tag
上级
01f6add4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
13 deletion
+42
-13
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/inc/taoserror.h
src/inc/taoserror.h
+2
-2
src/query/src/qFilter.c
src/query/src/qFilter.c
+28
-8
src/util/src/terror.c
src/util/src/terror.c
+2
-1
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+9
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
da60fb5e
...
...
@@ -4371,7 +4371,7 @@ static int32_t validateNullExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t
if
(
pRight
->
tokenId
==
TK_STRING
)
{
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
if
(
IS_VAR_DATA_TYPE
(
pSchema
[
index
].
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pSchema
[
index
].
type
)
||
pSchema
[
index
].
type
==
TSDB_DATA_TYPE_JSON
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
src/inc/taoserror.h
浏览文件 @
da60fb5e
...
...
@@ -288,10 +288,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica")
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition")
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
//#define TSDB_CODE_QRY_JSON_KEY_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x070F) //"json tag key not exist
")
#define TSDB_CODE_QRY_JSON_SUPPORT_ERROR TAOS_DEF_ERROR_CODE(0, 0x070F) //"only support is [not] null
")
#define TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0710) //"json tag key type not match")
#define TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR TAOS_DEF_ERROR_CODE(0, 0x0711) //"json tag key must be string in match/nmatch")
#define TSDB_CODE_QRY_JSON_INVALID_EXP TAOS_DEF_ERROR_CODE(0, 0x0712) // "invalid regular expression")
// grant
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired")
#define TSDB_CODE_GRANT_DNODE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x0801) //"DNode creation limited by licence")
...
...
src/query/src/qFilter.c
浏览文件 @
da60fb5e
...
...
@@ -1154,8 +1154,6 @@ _return:
return
code
;
}
int32_t
filterAddGroupUnitFromNode
(
SFilterInfo
*
info
,
tExprNode
*
tree
,
SArray
*
group
)
{
tExprNode
*
pLeft
=
tree
->
_node
.
pLeft
;
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
&&
pLeft
->
_node
.
optr
==
TSDB_RELATION_ARROW
){
// json tag -> operation
...
...
@@ -1172,19 +1170,41 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
assert
(
schema
->
type
>
TSDB_DATA_TYPE_NULL
&&
schema
->
type
<
TSDB_DATA_TYPE_JSON
);
}
pLeft
=
pLeft
->
_node
.
pLeft
;
// -> operation use left as input
if
(
IS_VAR_DATA_TYPE
(
tree
->
_node
.
pRight
->
pVal
->
nType
))
{
schema
=
pLeft
->
pSchema
;
if
(
!
IS_VAR_DATA_TYPE
(
schema
->
type
))
{
char
*
v
=
strndup
(
tree
->
_node
.
pRight
->
pVal
->
pz
,
tree
->
_node
.
pRight
->
pVal
->
nLen
);
uint32_t
type
=
0
;
tGetToken
(
v
,
&
type
);
if
(
type
==
TK_NULL
)
{
free
(
v
);
return
TSDB_CODE_QRY_JSON_SUPPORT_ERROR
;
}
free
(
v
);
}
}
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_QUESTION
){
SSchema
*
schema
=
pLeft
->
pSchema
;
if
(
tree
->
_node
.
pRight
->
pVal
->
nLen
>
TSDB_MAX_JSON_KEY_LEN
)
return
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
;
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
jsonKeyMd5
(
tree
->
_node
.
pRight
->
pVal
->
pz
,
tree
->
_node
.
pRight
->
pVal
->
nLen
,
keyMd5
);
memcpy
(
schema
->
name
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
);
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_ISNULL
||
tree
->
_node
.
optr
==
TSDB_RELATION_NOTNULL
){
SSchema
*
schema
=
pLeft
->
pSchema
;
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
uint8_t
nullData
=
TSDB_DATA_JSON_NULL
;
jsonKeyMd5
(
&
nullData
,
1
,
keyMd5
);
memcpy
(
schema
->
name
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
);
}
SSchema
*
schema
=
pLeft
->
pSchema
;
if
(
schema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_ISNULL
||
tree
->
_node
.
optr
==
TSDB_RELATION_NOTNULL
){
char
keyMd5
[
TSDB_MAX_JSON_KEY_MD5_LEN
]
=
{
0
};
uint8_t
nullData
=
TSDB_DATA_JSON_NULL
;
jsonKeyMd5
(
&
nullData
,
1
,
keyMd5
);
memcpy
(
schema
->
name
,
keyMd5
,
TSDB_MAX_JSON_KEY_MD5_LEN
);
}
else
if
(
tree
->
_node
.
optr
==
TSDB_RELATION_MATCH
||
tree
->
_node
.
optr
==
TSDB_RELATION_NMATCH
||
tree
->
_node
.
optr
==
TSDB_RELATION_LIKE
){
if
(
!
IS_VAR_DATA_TYPE
(
schema
->
type
)){
return
TSDB_CODE_QRY_JSON_INVALID_EXP
;
}
}
}
SFilterFieldId
left
=
{
0
},
right
=
{
0
};
filterAddFieldFromNode
(
info
,
pLeft
,
&
left
);
...
...
src/util/src/terror.c
浏览文件 @
da60fb5e
...
...
@@ -294,9 +294,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_ENOUGH_BUFFER, "Query buffer limit ha
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INCONSISTAN
,
"File inconsistance in replica"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_INVALID_TIME_CONDITION
,
"One valid time range condition expected"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_SYS_ERROR
,
"System error"
)
//TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_KEY_NOT_EXIST, "json tag key not exist
")
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_JSON_SUPPORT_ERROR
,
"only support is [not] null
"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR
,
"json tag key type not match"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR
,
"json tag key must be string in match/nmatch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_JSON_INVALID_EXP
,
"invalid regular expression"
)
// grant
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_EXPIRED
,
"License expired"
)
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
da60fb5e
...
...
@@ -145,6 +145,8 @@ 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%'"
)
# test where condition in
tdSql
.
query
(
"select * from db_json_tag_test.jsons1 where jtag->'location' in ('beijing')"
)
tdSql
.
checkRows
(
2
)
...
...
@@ -169,7 +171,7 @@ class TDTestCase:
tdSql
.
error
(
"select * from db_json_tag_test.jsons1 where jtag->'num' match '5'"
)
# test json
# 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')"
)
tdSql
.
error
(
"CREATE TABLE if not exists db_json_tag_test.jsons1_5 using db_json_tag_test.jsons1 tags('
\t
')"
)
tdSql
.
execute
(
"CREATE TABLE if not exists db_json_tag_test.jsons1_6 using db_json_tag_test.jsons1 tags('')"
)
...
...
@@ -207,6 +209,12 @@ class TDTestCase:
tdSql
.
query
(
"select jtag from db_json_tag_test.jsons1 where jtag is not null"
)
tdSql
.
checkRows
(
5
)
#tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location'='null'")
#tdSql.checkRows(5)
#tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'num'='null'")
#tdSql.checkRows(5)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录