Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db34294b
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看板
提交
db34294b
编写于
6月 22, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt: filter by tag
上级
e7faf699
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
183 addition
and
154 deletion
+183
-154
include/common/tdatablock.h
include/common/tdatablock.h
+2
-1
include/common/tdataformat.h
include/common/tdataformat.h
+2
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-2
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+12
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+0
-3
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-0
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+31
-9
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+130
-136
未找到文件。
include/common/tdatablock.h
浏览文件 @
db34294b
...
...
@@ -71,7 +71,8 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataGetData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
#define IS_JSON_NULL(type, data) ((type) == TSDB_DATA_TYPE_JSON && *(data) == TSDB_DATA_TYPE_NULL)
#define IS_JSON_NULL(type, data) ((type) == TSDB_DATA_TYPE_JSON && \
(*(data) == TSDB_DATA_TYPE_NULL || tTagIsJsonNull(data)))
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
...
...
include/common/tdataformat.h
浏览文件 @
db34294b
...
...
@@ -70,6 +70,8 @@ int32_t tGetTSRow(uint8_t *p, STSRow2 *pRow);
// STag
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
void
tTagFree
(
STag
*
pTag
);
bool
tTagIsJson
(
const
void
*
pTag
);
bool
tTagIsJsonNull
(
void
*
tagVal
);
bool
tTagGet
(
const
STag
*
pTag
,
STagVal
*
pTagVal
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
...
...
source/client/src/clientImpl.c
浏览文件 @
db34294b
...
...
@@ -1581,7 +1581,7 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
char
*
jsonInnerData
=
data
+
CHAR_BYTES
;
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
len
+=
(
VARSTR_HEADER_SIZE
+
strlen
(
TSDB_DATA_NULL_STR_L
));
}
else
if
(
jsonInnerType
&
TD_TAG_JSON
)
{
}
else
if
(
tTagIsJson
(
data
)
)
{
len
+=
(
VARSTR_HEADER_SIZE
+
((
const
STag
*
)(
data
))
->
len
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
len
+=
varDataTLen
(
jsonInnerData
)
+
CHAR_BYTES
*
2
;
...
...
@@ -1666,7 +1666,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
&
TD_TAG_JSON
)
{
}
else
if
(
tTagIsJson
(
data
)
)
{
char
*
jsonString
=
parseTagDatatoJson
(
data
);
STR_TO_VARSTR
(
dst
,
jsonString
);
taosMemoryFree
(
jsonString
);
...
...
source/common/src/tdatablock.c
浏览文件 @
db34294b
...
...
@@ -110,7 +110,7 @@ int32_t getJsonValueLen(const char* data) {
dataLen
=
DOUBLE_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
&
TD_TAG_JSON
)
{
// json string
}
else
if
(
tTagIsJson
(
data
)
)
{
// json string
dataLen
=
((
STag
*
)(
data
))
->
len
;
}
else
{
ASSERT
(
0
);
...
...
source/common/src/tdataformat.c
浏览文件 @
db34294b
...
...
@@ -924,6 +924,18 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
return
n
;
}
bool
tTagIsJson
(
const
void
*
pTag
){
return
(((
const
STag
*
)
pTag
)
->
flags
&
TD_TAG_JSON
);
}
bool
tTagIsJsonNull
(
void
*
data
){
STag
*
pTag
=
(
STag
*
)
data
;
int8_t
isJson
=
tTagIsJson
(
pTag
);
if
(
!
isJson
)
return
false
;
return
((
STag
*
)
data
)
->
nTag
==
0
;
}
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
)
{
int32_t
code
=
0
;
uint8_t
*
p
=
NULL
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
db34294b
...
...
@@ -613,9 +613,6 @@ const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *val) {
ASSERT
(
pEntry
->
type
==
TSDB_CHILD_TABLE
);
STag
*
tag
=
(
STag
*
)
pEntry
->
ctbEntry
.
pTags
;
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
tag
->
nTag
==
0
)
{
return
NULL
;
}
return
tag
;
}
bool
find
=
tTagGet
(
tag
,
val
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
db34294b
...
...
@@ -337,7 +337,7 @@ void addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_
}
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
colDataAppend
(
pColInfoData
,
i
,
data
,
(
data
==
NULL
));
colDataAppend
(
pColInfoData
,
i
,
data
,
(
data
==
NULL
)
||
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
tTagIsJsonNull
(
data
))
);
}
if
(
data
&&
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
)
&&
p
!=
NULL
&&
...
...
@@ -1824,7 +1824,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
}
else
{
data
=
(
char
*
)
p
;
}
colDataAppend
(
pDst
,
count
,
data
,
(
data
==
NULL
));
colDataAppend
(
pDst
,
count
,
data
,
(
data
==
NULL
)
||
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
tTagIsJsonNull
(
data
))
);
if
(
pDst
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
&&
p
!=
NULL
&&
IS_VAR_DATA_TYPE
(((
const
STagVal
*
)
p
)
->
type
)
&&
data
!=
NULL
)
{
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
db34294b
...
...
@@ -1135,6 +1135,7 @@ void* nodesGetValueFromNode(SValueNode* pNode) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_JSON
:
return
(
void
*
)
pNode
->
datum
.
p
;
default:
break
;
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
db34294b
...
...
@@ -23,6 +23,7 @@
#include "sclvector.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdataformat.h"
#include "ttypes.h"
#include "ttime.h"
...
...
@@ -506,6 +507,16 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
}
}
// if types can not comparable
if
((
IS_NUMERIC_TYPE
(
typeLeft
)
&&
!
IS_NUMERIC_TYPE
(
typeRight
))
||
(
IS_NUMERIC_TYPE
(
typeRight
)
&&
!
IS_NUMERIC_TYPE
(
typeLeft
))
||
(
IS_VAR_DATA_TYPE
(
typeLeft
)
&&
!
IS_VAR_DATA_TYPE
(
typeRight
))
||
(
IS_VAR_DATA_TYPE
(
typeRight
)
&&
!
IS_VAR_DATA_TYPE
(
typeLeft
))
||
((
typeLeft
==
TSDB_DATA_TYPE_BOOL
)
&&
(
typeRight
!=
TSDB_DATA_TYPE_BOOL
))
||
((
typeRight
==
TSDB_DATA_TYPE_BOOL
)
&&
(
typeLeft
!=
TSDB_DATA_TYPE_BOOL
)))
return
false
;
if
(
typeLeft
==
TSDB_DATA_TYPE_NULL
||
typeRight
==
TSDB_DATA_TYPE_NULL
){
*
isNull
=
true
;
return
true
;
...
...
@@ -519,24 +530,28 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*
fp
=
filterGetCompFunc
(
type
,
optr
);
if
(
IS_NUMERIC_TYPE
(
type
)
||
IS_FLOAT_TYPE
(
type
)
){
if
(
IS_NUMERIC_TYPE
(
type
)){
if
(
typeLeft
==
TSDB_DATA_TYPE_NCHAR
)
{
convertNcharToDouble
(
*
pLeftData
,
pLeftOut
);
*
pLeftData
=
pLeftOut
;
ASSERT
(
0
);
// convertNcharToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
}
else
if
(
typeLeft
==
TSDB_DATA_TYPE_BINARY
)
{
convertBinaryToDouble
(
*
pLeftData
,
pLeftOut
);
*
pLeftData
=
pLeftOut
;
ASSERT
(
0
);
// convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
}
else
if
(
typeLeft
!=
type
)
{
convertNumberToNumber
(
*
pLeftData
,
pLeftOut
,
typeLeft
,
type
);
*
pLeftData
=
pLeftOut
;
}
if
(
typeRight
==
TSDB_DATA_TYPE_NCHAR
)
{
convertNcharToDouble
(
*
pRightData
,
pRightOut
);
*
pRightData
=
pRightOut
;
ASSERT
(
0
);
// convertNcharToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
}
else
if
(
typeRight
==
TSDB_DATA_TYPE_BINARY
)
{
convertBinaryToDouble
(
*
pRightData
,
pRightOut
);
*
pRightData
=
pRightOut
;
ASSERT
(
0
);
// convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
}
else
if
(
typeRight
!=
type
)
{
convertNumberToNumber
(
*
pRightData
,
pRightOut
,
typeRight
,
type
);
*
pRightData
=
pRightOut
;
...
...
@@ -1693,6 +1708,13 @@ void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
STagVal
getJsonValue
(
char
*
json
,
char
*
key
,
bool
*
isExist
)
{
STagVal
val
=
{.
pKey
=
key
};
if
(
tTagIsJson
((
const
STag
*
)
json
)
==
false
){
if
(
isExist
){
*
isExist
=
false
;
}
return
val
;
}
bool
find
=
tTagGet
(((
const
STag
*
)
json
),
&
val
);
// json value is null and not exist is different
if
(
isExist
){
*
isExist
=
find
;
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
db34294b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录