Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3a95904
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看板
提交
a3a95904
编写于
6月 05, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: test arith/logic operator for json
上级
30b8bd1b
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
28 addition
and
23 deletion
+28
-23
include/util/tdef.h
include/util/tdef.h
+1
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1
-1
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
+20
-15
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+3
-3
未找到文件。
include/util/tdef.h
浏览文件 @
a3a95904
...
...
@@ -129,7 +129,7 @@ typedef enum EOperatorType {
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_
MOD
,
OP_TYPE_
REM
,
// unary arithmetic operator
OP_TYPE_MINUS
,
OP_TYPE_ASSIGN
,
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
a3a95904
...
...
@@ -1089,7 +1089,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
case
OP_TYPE_SUB
:
case
OP_TYPE_MULTI
:
case
OP_TYPE_DIV
:
case
OP_TYPE_
MOD
:
case
OP_TYPE_
REM
:
return
true
;
default:
break
;
...
...
source/libs/parser/inc/sql.y
浏览文件 @
a3a95904
...
...
@@ -608,7 +608,7 @@ expression(A) ::= expression(B) NK_SLASH expression(C).
expression(A) ::= expression(B) NK_REM expression(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken e = getTokenFromRawExprNode(pCxt, C);
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_
MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_
REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
}
expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
...
...
source/libs/parser/src/sql.c
浏览文件 @
a3a95904
...
...
@@ -4540,7 +4540,7 @@ static YYACTIONTYPE yy_reduce(
{
SToken
s
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy686
);
SToken
e
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy686
);
yylhsminor
.
yy686
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createOperatorNode
(
pCxt
,
OP_TYPE_
MOD
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy686
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy686
)));
yylhsminor
.
yy686
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createOperatorNode
(
pCxt
,
OP_TYPE_
REM
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy686
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy686
)));
}
yymsp
[
-
2
].
minor
.
yy686
=
yylhsminor
.
yy686
;
break
;
...
...
source/libs/scalar/src/filter.c
浏览文件 @
a3a95904
...
...
@@ -29,7 +29,7 @@ OptrStr gOptrStr[] = {
{
OP_TYPE_SUB
,
"-"
},
{
OP_TYPE_MULTI
,
"*"
},
{
OP_TYPE_DIV
,
"/"
},
{
OP_TYPE_
MOD
,
"%"
},
{
OP_TYPE_
REM
,
"%"
},
{
OP_TYPE_MINUS
,
"minus"
},
{
OP_TYPE_ASSIGN
,
"assign"
},
// bit operator
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
a3a95904
...
...
@@ -1245,8 +1245,8 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
SColumnInfoData
*
pLeftCol
=
doVectorConvert
(
pLeft
,
&
leftConvert
);
SColumnInfoData
*
pRightCol
=
doVectorConvert
(
pRight
,
&
rightConvert
);
_get
BigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigint
ValueFn
(
pLeftCol
->
info
.
type
);
_get
BigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigint
ValueFn
(
pRightCol
->
info
.
type
);
_get
DoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDouble
ValueFn
(
pLeftCol
->
info
.
type
);
_get
DoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDouble
ValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
...
...
@@ -1257,17 +1257,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
}
int64_t
lx
=
getVectorBigint
ValueFnLeft
(
LEFT_COL
,
i
);
int64_t
rx
=
getVectorBigint
ValueFnRight
(
RIGHT_COL
,
i
);
if
(
rx
==
0
)
{
double
lx
=
getVectorDouble
ValueFnLeft
(
LEFT_COL
,
i
);
double
rx
=
getVectorDouble
ValueFnRight
(
RIGHT_COL
,
i
);
if
(
isnan
(
lx
)
||
isinf
(
lx
)
||
isnan
(
rx
)
||
isinf
(
rx
)
||
FLT_EQUAL
(
rx
,
0
)
)
{
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
}
*
output
=
lx
%
rx
;
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
int64_t
lx
=
getVectorBigint
ValueFnLeft
(
LEFT_COL
,
0
);
double
lx
=
getVectorDouble
ValueFnLeft
(
LEFT_COL
,
0
);
if
(
IS_HELPER_NULL
(
pLeftCol
,
0
))
{
// Set pLeft->numOfRows NULL value
colDataAppendNNULL
(
pOutputCol
,
0
,
pRight
->
numOfRows
);
}
else
{
...
...
@@ -1277,18 +1277,18 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
}
int64_t
rx
=
getVectorBigint
ValueFnRight
(
RIGHT_COL
,
i
);
if
(
rx
==
0
)
{
double
rx
=
getVectorDouble
ValueFnRight
(
RIGHT_COL
,
i
);
if
(
isnan
(
rx
)
||
isinf
(
rx
)
||
FLT_EQUAL
(
rx
,
0
))
{
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
}
*
output
=
lx
%
rx
;
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
}
else
if
(
pRight
->
numOfRows
==
1
)
{
int64_t
rx
=
getVectorBigint
ValueFnRight
(
RIGHT_COL
,
0
);
if
(
IS_HELPER_NULL
(
pRightCol
,
0
)
||
rx
==
0
)
{
// Set pLeft->numOfRows NULL value
double
rx
=
getVectorDouble
ValueFnRight
(
RIGHT_COL
,
0
);
if
(
IS_HELPER_NULL
(
pRightCol
,
0
)
||
FLT_EQUAL
(
rx
,
0
)
)
{
// Set pLeft->numOfRows NULL value
colDataAppendNNULL
(
pOutputCol
,
0
,
pLeft
->
numOfRows
);
}
else
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
...
...
@@ -1297,8 +1297,13 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
}
int64_t
lx
=
getVectorBigintValueFnLeft
(
LEFT_COL
,
i
);
*
output
=
lx
%
rx
;
double
lx
=
getVectorDoubleValueFnLeft
(
LEFT_COL
,
i
);
if
(
isnan
(
lx
)
||
isinf
(
lx
))
{
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
}
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
}
...
...
@@ -1712,7 +1717,7 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
return
vectorMathMultiply
;
case
OP_TYPE_DIV
:
return
vectorMathDivide
;
case
OP_TYPE_
MOD
:
case
OP_TYPE_
REM
:
return
vectorMathRemainder
;
case
OP_TYPE_MINUS
:
return
vectorMathMinus
;
...
...
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
a3a95904
...
...
@@ -1061,7 +1061,7 @@ void makeJsonArrow(SSDataBlock **src, SNode **opNode, void *json, char *key){
void
makeOperator
(
SNode
**
opNode
,
SArray
*
blockList
,
EOperatorType
opType
,
int32_t
rightType
,
void
*
rightData
,
bool
isReverse
){
int32_t
resType
=
TSDB_DATA_TYPE_NULL
;
if
(
opType
==
OP_TYPE_ADD
||
opType
==
OP_TYPE_SUB
||
opType
==
OP_TYPE_MULTI
||
opType
==
OP_TYPE_DIV
||
opType
==
OP_TYPE_
MOD
||
opType
==
OP_TYPE_MINUS
){
opType
==
OP_TYPE_DIV
||
opType
==
OP_TYPE_
REM
||
opType
==
OP_TYPE_MINUS
){
resType
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
opType
==
OP_TYPE_BIT_AND
||
opType
==
OP_TYPE_BIT_OR
){
resType
=
TSDB_DATA_TYPE_BIGINT
;
...
...
@@ -1106,7 +1106,7 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
printf
(
"result:NULL
\n
"
);
}
else
if
(
opType
==
OP_TYPE_ADD
||
opType
==
OP_TYPE_SUB
||
opType
==
OP_TYPE_MULTI
||
opType
==
OP_TYPE_DIV
||
opType
==
OP_TYPE_
MOD
||
opType
==
OP_TYPE_MINUS
){
opType
==
OP_TYPE_
REM
||
opType
==
OP_TYPE_MINUS
){
printf
(
"op:%s,1result:%f,except:%f
\n
"
,
gOptrStr
[
opType
].
str
,
*
((
double
*
)
colDataGetData
(
column
,
0
)),
exceptValue
);
ASSERT_TRUE
(
fabs
(
*
((
double
*
)
colDataGetData
(
column
,
0
))
-
exceptValue
)
<
0.0001
);
}
else
if
(
opType
==
OP_TYPE_BIT_AND
||
opType
==
OP_TYPE_BIT_OR
){
...
...
@@ -1136,7 +1136,7 @@ TEST(columnTest, json_column_arith_op) {
const
int32_t
len
=
8
;
EOperatorType
op
[
len
]
=
{
OP_TYPE_ADD
,
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_MOD
,
OP_TYPE_MINUS
,
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_OR
};
OP_TYPE_REM
,
OP_TYPE_MINUS
,
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_OR
};
int32_t
input
[
len
]
=
{
1
,
8
,
2
,
2
,
3
,
0
,
-
4
,
9
};
printf
(
"--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录