Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
02323943
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
02323943
编写于
6月 06, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix error in json and add test cases for json
上级
bae49baa
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
10 deletion
+33
-10
include/util/tcompare.h
include/util/tcompare.h
+0
-2
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+6
-2
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+25
-0
source/util/src/tcompare.c
source/util/src/tcompare.c
+0
-5
未找到文件。
include/util/tcompare.h
浏览文件 @
02323943
...
...
@@ -105,8 +105,6 @@ int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight);
int32_t
compareWStrPatternMatch
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareWStrPatternNotMatch
(
const
void
*
pLeft
,
const
void
*
pRight
);
int32_t
compareJsonContainsKey
(
const
void
*
pLeft
,
const
void
*
pRight
);
__compar_fn_t
getComparFunc
(
int32_t
type
,
int32_t
optr
);
__compar_fn_t
getKeyComparFunc
(
int32_t
keyType
,
int32_t
order
);
int32_t
doCompare
(
const
char
*
a
,
const
char
*
b
,
int32_t
type
,
size_t
size
);
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
02323943
...
...
@@ -64,6 +64,7 @@ static SKeyword keywordTable[] = {
{
"CONSUMER"
,
TK_CONSUMER
},
{
"COUNT"
,
TK_COUNT
},
{
"CREATE"
,
TK_CREATE
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"DATABASE"
,
TK_DATABASE
},
{
"DATABASES"
,
TK_DATABASES
},
{
"DAYS"
,
TK_DAYS
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
02323943
...
...
@@ -847,8 +847,12 @@ static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pO
if
(
TSDB_DATA_TYPE_JSON
!=
ldt
.
type
||
TSDB_DATA_TYPE_BINARY
!=
rdt
.
type
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_JSON
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_JSON
].
bytes
;
if
(
pOp
->
opType
==
OP_TYPE_JSON_GET_VALUE
){
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_JSON
;
}
else
if
(
pOp
->
opType
==
OP_TYPE_JSON_CONTAINS
){
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
}
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
pOp
->
node
.
resType
.
type
].
bytes
;
return
DEAL_RES_CONTINUE
;
}
...
...
source/libs/scalar/src/filter.c
浏览文件 @
02323943
...
...
@@ -168,7 +168,7 @@ __compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val
compareLenPrefixedWStr
,
compareUint8Val
,
compareUint16Val
,
compareUint32Val
,
compareUint64Val
,
setChkInBytes1
,
setChkInBytes2
,
setChkInBytes4
,
setChkInBytes8
,
compareStrRegexCompMatch
,
compareStrRegexCompNMatch
,
setChkNotInBytes1
,
setChkNotInBytes2
,
setChkNotInBytes4
,
setChkNotInBytes8
,
compareChkNotInString
,
compareStrPatternNotMatch
,
compareWStrPatternNotMatch
,
compareJsonContainsKey
compareChkNotInString
,
compareStrPatternNotMatch
,
compareWStrPatternNotMatch
};
int8_t
filterGetCompFuncIdx
(
int32_t
type
,
int32_t
optr
)
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
02323943
...
...
@@ -944,6 +944,31 @@ STagVal getJsonValue(char *json, char *key, bool *isExist) {
return
val
;
}
void
vectorJsonContains
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
char
*
pRightData
=
colDataGetVarData
(
pRight
->
columnData
,
0
);
char
*
jsonKey
=
taosMemoryCalloc
(
1
,
varDataLen
(
pRightData
)
+
1
);
memcpy
(
jsonKey
,
varDataVal
(
pRightData
),
varDataLen
(
pRightData
));
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
)
{
bool
isExist
=
false
;
if
(
!
colDataIsNull_var
(
pLeft
->
columnData
,
i
))
{
char
*
pLeftData
=
colDataGetVarData
(
pLeft
->
columnData
,
i
);
getJsonValue
(
pLeftData
,
jsonKey
,
&
isExist
);
}
colDataAppend
(
pOutputCol
,
i
,
(
const
char
*
)(
&
isExist
),
false
);
}
taosMemoryFree
(
jsonKey
);
}
void
vectorJsonArrow
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
...
...
source/util/src/tcompare.c
浏览文件 @
02323943
...
...
@@ -222,11 +222,6 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight) {
return
compareLenPrefixedWStr
(
pRight
,
pLeft
);
}
int32_t
compareJsonContainsKey
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
if
(
pLeft
)
return
0
;
return
1
;
}
// string > number > bool > null
// ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison
int32_t
compareJsonVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录