Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de52faff
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
de52faff
编写于
12月 01, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable different value type of the same key in json
上级
3d868b5b
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
268 addition
and
145 deletion
+268
-145
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+12
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+0
-2
src/inc/taosdef.h
src/inc/taosdef.h
+1
-0
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+12
-1
src/query/src/qFilter.c
src/query/src/qFilter.c
+2
-0
src/util/src/tcompare.c
src/util/src/tcompare.c
+19
-5
src/util/src/tutil.c
src/util/src/tutil.c
+1
-1
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+221
-135
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
de52faff
...
...
@@ -747,7 +747,18 @@ int32_t tagValCompar(const void* p1, const void* p2) {
}
else
if
(
!
f1IsNull
&&
f2IsNull
){
return
1
;
}
else
{
assert
(
*
t1
->
tag
==
*
t1
->
tag
);
bool
f1IsJsonNull
=
(
*
t1
->
tag
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
t1
->
tag
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
bool
f2IsJsonNull
=
(
*
t2
->
tag
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
t2
->
tag
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
if
(
f1IsJsonNull
&&
f2IsJsonNull
){
return
0
;
}
else
if
(
f1IsJsonNull
&&
!
f2IsJsonNull
){
return
-
1
;
}
else
if
(
!
f1IsJsonNull
&&
f2IsJsonNull
)
{
return
1
;
}
if
(
*
t1
->
tag
!=
*
t2
->
tag
)
{
return
1
;
}
__compar_fn_t
func
=
getComparFunc
(
t1
->
tag
[
0
],
0
);
return
func
(
t1
->
tag
+
CHAR_BYTES
,
t2
->
tag
+
CHAR_BYTES
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
de52faff
...
...
@@ -5602,7 +5602,6 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
}
char
*
jsonKey
=
item
->
string
;
if
(
strtrim
(
jsonKey
)
==
0
)
continue
;
if
(
!
isValidateTag
(
jsonKey
)){
tscError
(
"json key not validate"
);
retCode
=
tscSQLSyntaxErrMsg
(
errMsg
,
"json key not validate"
,
NULL
);
...
...
@@ -5629,7 +5628,6 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
if
(
item
->
type
==
cJSON_String
){
// add json value format: type|data
char
*
jsonValue
=
item
->
valuestring
;
strtrim
(
jsonValue
);
outLen
=
0
;
char
tagVal
[
TSDB_MAX_JSON_TAGS_LEN
]
=
{
0
};
*
tagVal
=
jsonType2DbType
(
0
,
item
->
type
);
// type
...
...
src/inc/taosdef.h
浏览文件 @
de52faff
...
...
@@ -74,6 +74,7 @@ extern const int32_t TYPE_BYTES[16];
#define TSDB_DATA_JSON_NULL 0xFFFFFFFF
#define TSDB_DATA_JSON_null 0xFFFFFFFE
#define TSDB_DATA_JSON_NOT_NULL 0x01
#define TSDB_DATA_JSON_CAN_NOT_COMPARE 0x7FFFFFFF
#define TSDB_DATA_UTINYINT_NULL 0xFF
#define TSDB_DATA_USMALLINT_NULL 0xFFFF
...
...
src/query/src/qExtbuffer.c
浏览文件 @
de52faff
...
...
@@ -377,7 +377,18 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
}
else
if
(
!
f1IsNull
&&
f2IsNull
){
return
1
;
}
else
{
assert
(
*
f1
==
*
f2
);
bool
f1IsJsonNull
=
(
*
f1
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
f1
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
bool
f2IsJsonNull
=
(
*
f2
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
f1
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
if
(
f1IsJsonNull
&&
f2IsJsonNull
){
return
0
;
}
else
if
(
f1IsJsonNull
&&
!
f2IsJsonNull
){
return
-
1
;
}
else
if
(
!
f1IsJsonNull
&&
f2IsJsonNull
)
{
return
1
;
}
if
(
*
f1
!=
*
f2
)
{
return
1
;
}
type
=
*
f1
;
f1
+=
CHAR_BYTES
;
f2
+=
CHAR_BYTES
;
...
...
src/query/src/qFilter.c
浏览文件 @
de52faff
...
...
@@ -1910,6 +1910,8 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
bool
filterDoCompare
(
__compar_fn_t
func
,
uint8_t
optr
,
void
*
left
,
void
*
right
)
{
int32_t
ret
=
func
(
left
,
right
);
if
(
ret
==
TSDB_DATA_JSON_CAN_NOT_COMPARE
)
return
false
;
switch
(
optr
)
{
case
TSDB_RELATION_EQUAL
:
{
return
ret
==
0
;
...
...
src/util/src/tcompare.c
浏览文件 @
de52faff
...
...
@@ -220,17 +220,21 @@ int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) {
}
int32_t
compareJsonVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
if
(
*
(
char
*
)
pLeft
==
TSDB_DATA_TYPE_BINARY
){
// json null
return
-
1
;
}
const
tVariant
*
right
=
pRight
;
if
(
right
->
nType
!=
*
(
char
*
)
pLeft
)
return
-
1
;
if
(
right
->
nType
!=
*
(
char
*
)
pLeft
&&
!
(
IS_NUMERIC_TYPE
(
right
->
nType
)
&&
IS_NUMERIC_TYPE
(
*
(
char
*
)
pLeft
)))
return
TSDB_DATA_JSON_CAN_NOT_COMPARE
;
uint8_t
type
=
*
(
char
*
)
pLeft
;
char
*
realData
=
POINTER_SHIFT
(
pLeft
,
CHAR_BYTES
);
if
(
type
==
TSDB_DATA_TYPE_BOOL
)
{
DEFAULT_COMP
(
GET_INT8_VAL
(
realData
),
right
->
i64
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
){
DEFAULT_COMP
(
GET_INT64_VAL
(
realData
),
right
->
i64
);
DEFAULT_COMP
(
GET_INT64_VAL
(
realData
),
(
right
->
nType
==
TSDB_DATA_TYPE_BIGINT
)
?
right
->
i64
:
right
->
dKey
);
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
){
DEFAULT_DOUBLE_COMP
(
GET_DOUBLE_VAL
(
realData
),
right
->
dKey
);
DEFAULT_DOUBLE_COMP
(
GET_DOUBLE_VAL
(
realData
),
(
right
->
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
right
->
dKey
:
right
->
i64
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
varDataLen
(
realData
)
!=
right
->
nLen
)
{
return
varDataLen
(
realData
)
>
right
->
nLen
?
1
:
-
1
;
...
...
@@ -243,7 +247,6 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) {
}
else
{
assert
(
0
);
}
return
0
;
}
/*
...
...
@@ -624,7 +627,18 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
}
else
if
(
!
f1IsNull
&&
f2IsNull
){
return
1
;
}
else
{
assert
(
*
f1
==
*
f2
);
bool
f1IsJsonNull
=
(
*
f1
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
f1
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
bool
f2IsJsonNull
=
(
*
f2
==
TSDB_DATA_TYPE_BINARY
&&
*
(
uint32_t
*
)(
f1
+
CHAR_BYTES
)
==
TSDB_DATA_JSON_null
);
if
(
f1IsJsonNull
&&
f2IsJsonNull
){
return
0
;
}
else
if
(
f1IsJsonNull
&&
!
f2IsJsonNull
){
return
-
1
;
}
else
if
(
!
f1IsJsonNull
&&
f2IsJsonNull
)
{
return
1
;
}
if
(
*
f1
!=
*
f2
)
{
return
1
;
}
type
=
*
f1
;
f1
+=
CHAR_BYTES
;
f2
+=
CHAR_BYTES
;
...
...
src/util/src/tutil.c
浏览文件 @
de52faff
...
...
@@ -528,7 +528,7 @@ bool isValidateTag(char *input) {
if
(
!
input
)
return
false
;
int
len
=
strlen
(
input
);
if
(
len
==
0
)
return
false
;
for
(
int
i
=
1
;
i
<
len
;
++
i
)
{
for
(
int
i
=
0
;
i
<
len
;
++
i
)
{
if
(
isprint
(
input
[
i
])
==
0
)
return
false
;
}
return
true
;
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
de52faff
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录