Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a52725f1
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看板
提交
a52725f1
编写于
10月 26, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify tree traverse for function node
上级
9bd02b1c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
135 addition
and
47 deletion
+135
-47
src/client/src/tscGlobalmerge.c
src/client/src/tscGlobalmerge.c
+1
-1
src/common/inc/tarithoperator.h
src/common/inc/tarithoperator.h
+11
-0
src/common/inc/texpr.h
src/common/inc/texpr.h
+11
-2
src/common/src/tarithoperator.c
src/common/src/tarithoperator.c
+15
-0
src/common/src/texpr.c
src/common/src/texpr.c
+95
-33
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+1
-10
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+1
-1
未找到文件。
src/client/src/tscGlobalmerge.c
浏览文件 @
a52725f1
...
...
@@ -734,7 +734,7 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
// calculate the result from several other columns
if
(
pSup
->
pExpr
->
pExpr
!=
NULL
)
{
arithSup
.
pExprInfo
=
pSup
->
pExpr
;
arithmeticTre
eTraverse
(
arithSup
.
pExprInfo
->
pExpr
,
(
int32_t
)
pOutput
->
num
,
pbuf
+
pOutput
->
num
*
offset
,
&
arithSup
,
TSDB_ORDER_ASC
,
getArithmeticInputSrc
);
exprTreeInternalNod
eTraverse
(
arithSup
.
pExprInfo
->
pExpr
,
(
int32_t
)
pOutput
->
num
,
pbuf
+
pOutput
->
num
*
offset
,
&
arithSup
,
TSDB_ORDER_ASC
,
getArithmeticInputSrc
);
}
else
{
SExprInfo
*
pExpr
=
pSup
->
pExpr
;
memcpy
(
pbuf
+
pOutput
->
num
*
offset
,
pExpr
->
base
.
offset
*
pOutput
->
num
+
pOutput
->
data
,
(
size_t
)(
pExpr
->
base
.
resBytes
*
pOutput
->
num
));
...
...
src/common/inc/tarithoperator.h
浏览文件 @
a52725f1
...
...
@@ -19,12 +19,23 @@
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int16_t
type
;
int16_t
bytes
;
int16_t
numOfRows
;
char
*
data
;
}
tExprOperandInfo
;
typedef
void
(
*
_arithmetic_operator_fn_t
)(
void
*
left
,
int32_t
numLeft
,
int32_t
leftType
,
void
*
right
,
int32_t
numRight
,
int32_t
rightType
,
void
*
output
,
int32_t
order
);
_arithmetic_operator_fn_t
getArithmeticOperatorFn
(
int32_t
arithmeticOptr
);
typedef
void
(
*
_expr_scalar_function_t
)(
tExprOperandInfo
*
pInputs
,
uint8_t
numInputs
,
tExprOperandInfo
*
pOutput
,
int32_t
order
);
_expr_scalar_function_t
getExprScalarFunction
(
uint16_t
scalar
);
#ifdef __cplusplus
}
#endif
...
...
src/common/inc/texpr.h
浏览文件 @
a52725f1
...
...
@@ -41,6 +41,15 @@ struct SSchema;
#define QUERY_COND_REL_PREFIX_MATCH_LEN 6
#define QUERY_COND_REL_PREFIX_NMATCH_LEN 7
#define TSDB_FUNC_FLAG_UDF 0x8000
#define TSDB_FUNC_FLAG_SCALAR 0x4000
#define TSDB_FUNC_IS_SCALAR(id) ((((id) & TSDB_FUNC_FLAG_UDF) == 0) && (((id) & TSDB_FUNC_FLAG_SCALAR) != 0))
#define TSDB_FUNC_SCALAR_INDEX(id) ((id) & ~TSDB_FUNC_FLAG_SCALAR)
///////////////////////////////////////////
// SCALAR FUNCTIONS
#define TSDB_FUNC_SCALAR_POW (TSDB_FUNC_FLAG_SCALAR | 0x0000)
#define TSDB_FUNC_SCALAR_LOG (TSDB_FUNC_FLAG_SCALAR | 0x0001)
#define TSDB_FUNC_SCALAR_MAX_NUM 2
typedef
bool
(
*
__result_filter_fn_t
)(
const
void
*
,
void
*
);
typedef
void
(
*
__do_filter_suppl_fn_t
)(
void
*
,
void
*
);
...
...
@@ -102,8 +111,8 @@ void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
bool
exprTreeApplyFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
);
void
arithmeticTreeTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
void
exprTreeInternalNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
));
void
buildFilterSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
);
...
...
src/common/src/tarithoperator.c
浏览文件 @
a52725f1
...
...
@@ -19,6 +19,7 @@
#include "tutil.h"
#include "tarithoperator.h"
#include "tcompare.h"
#include "texpr.h"
//GET_TYPED_DATA(v, double, _right_type, (char *)&((right)[i]));
...
...
@@ -410,3 +411,17 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) {
return
NULL
;
}
}
void
vectorPow
(
tExprOperandInfo
*
pInputs
,
uint8_t
numInputs
,
tExprOperandInfo
*
pOutput
,
int32_t
order
)
{
}
_expr_scalar_function_t
getExprScalarFunction
(
uint16_t
scalarFunc
)
{
switch
(
scalarFunc
)
{
case
TSDB_FUNC_SCALAR_POW
:
return
vectorPow
;
default:
assert
(
0
);
return
NULL
;
}
}
\ No newline at end of file
src/common/src/texpr.c
浏览文件 @
a52725f1
...
...
@@ -180,63 +180,125 @@ bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp
return
param
->
nodeFilterFn
(
pItem
,
pExpr
->
_node
.
info
);
}
void
arithmeticTreeTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
if
(
pExprs
==
NULL
)
{
return
;
void
exprTreeExprNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
));
void
exprTreeFunctionNodeTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
));
void
exprTreeInternalNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
));
void
exprTreeInternalNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
if
(
pExpr
->
nodeType
==
TSQL_NODE_FUNC
)
{
exprTreeFunctionNodeTraverse
(
pExpr
,
numOfRows
,
pOutput
,
param
,
order
,
getSourceDataBlock
);
}
else
if
(
pExpr
->
nodeType
==
TSQL_NODE_EXPR
){
exprTreeExprNodeTraverse
(
pExpr
,
numOfRows
,
pOutput
,
param
,
order
,
getSourceDataBlock
);
}
}
void
exprTreeFunctionNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
uint8_t
numChildren
=
pExpr
->
_func
.
numChildren
;
char
**
pChildrenOutput
=
calloc
(
numChildren
,
sizeof
(
char
*
));
tExprOperandInfo
*
pInputs
=
calloc
(
numChildren
,
sizeof
(
tExprOperandInfo
));
for
(
int
i
=
0
;
i
<
numChildren
;
++
i
)
{
pInputs
[
i
].
type
=
TSDB_DATA_TYPE_DOUBLE
;
pInputs
[
i
].
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
pInputs
[
i
].
numOfRows
=
numOfRows
;
}
for
(
int
i
=
0
;
i
<
numChildren
;
++
i
)
{
tExprNode
*
pChild
=
pExpr
->
_func
.
pChildren
[
i
];
if
(
pChild
->
nodeType
==
TSQL_NODE_EXPR
||
pChild
->
nodeType
==
TSQL_NODE_FUNC
)
{
pChildrenOutput
[
i
]
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
exprTreeInternalNodeTraverse
(
pChild
,
numOfRows
,
pChildrenOutput
[
i
],
param
,
order
,
getSourceDataBlock
);
pInputs
[
i
].
data
=
pChildrenOutput
[
i
];
}
else
if
(
pChild
->
nodeType
==
TSQL_NODE_COL
)
{
char
*
pInputData
=
getSourceDataBlock
(
param
,
pChild
->
pSchema
->
name
,
pChild
->
pSchema
->
colId
);
if
(
order
==
TSDB_ORDER_DESC
)
{
pChildrenOutput
[
i
]
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
reverseCopy
(
pChildrenOutput
[
i
],
pInputData
,
pChild
->
pSchema
->
type
,
numOfRows
);
pInputs
[
i
].
data
=
pInputData
;
}
else
{
pInputs
[
i
].
data
=
pInputData
;
}
}
else
if
(
pChild
->
nodeType
==
TSQL_NODE_VALUE
)
{
pInputs
[
i
].
data
=
(
char
*
)
&
(
pChild
->
pVal
->
dKey
);
pInputs
[
i
].
numOfRows
=
1
;
}
}
tExprNode
*
pLeft
=
pExprs
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExprs
->
_node
.
pRight
;
_expr_scalar_function_t
scalarFn
=
getExprScalarFunction
(
pExpr
->
_func
.
functionId
);
tExprOperandInfo
output
;
output
.
data
=
pOutput
;
output
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
output
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
scalarFn
(
pInputs
,
numChildren
,
&
output
,
order
);
for
(
int
i
=
0
;
i
<
numChildren
;
++
i
)
{
tfree
(
pChildrenOutput
[
i
]);
}
tfree
(
pInputs
);
tfree
(
pChildrenOutput
);
}
void
exprTreeExprNodeTraverse
(
tExprNode
*
pExpr
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
tExprNode
*
pLeft
=
pExpr
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExpr
->
_node
.
pRight
;
/* the left output has result from the left child syntax tree */
char
*
pLeftOutput
=
(
char
*
)
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
)
{
arithmeticTre
eTraverse
(
pLeft
,
numOfRows
,
pLeftOutput
,
param
,
order
,
getSourceDataBlock
);
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
||
pLeft
->
nodeType
==
TSQL_NODE_FUNC
)
{
exprTreeInternalNod
eTraverse
(
pLeft
,
numOfRows
,
pLeftOutput
,
param
,
order
,
getSourceDataBlock
);
}
/* the right output has result from the right child syntax tree */
char
*
pRightOutput
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
char
*
p
d
ata
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
char
*
p
D
ata
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
arithmeticTre
eTraverse
(
pRight
,
numOfRows
,
pRightOutput
,
param
,
order
,
getSourceDataBlock
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
||
pRight
->
nodeType
==
TSQL_NODE_FUNC
)
{
exprTreeInternalNod
eTraverse
(
pRight
,
numOfRows
,
pRightOutput
,
param
,
order
,
getSourceDataBlock
);
}
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
||
pLeft
->
nodeType
==
TSQL_NODE_FUNC
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
||
pRight
->
nodeType
==
TSQL_NODE_FUNC
)
{
/*
* exprLeft + exprRight
* the type of returned value of one expression is always double float precious
*/
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// exprLeft + columnRight
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
// set input buffer
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
p
d
ata
,
pInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
p
d
ata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
reverseCopy
(
p
D
ata
,
pInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
p
D
ata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// exprLeft + 12
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
// column data specified on left-hand-side
char
*
pLeftInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// columnLeft + expr2
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
||
pRight
->
nodeType
==
TSQL_NODE_FUNC
)
{
// columnLeft + expr2
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
p
d
ata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
p
d
ata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
reverseCopy
(
p
D
ata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
p
D
ata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
...
...
@@ -244,45 +306,45 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// columnLeft + columnRight
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
// both columns are descending order, do not reverse the source data
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
order
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// columnLeft + 12
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
p
d
ata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
p
d
ata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
reverseCopy
(
p
D
ata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
p
D
ata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
}
else
{
// column data specified on left-hand-side
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// 12 + expr2
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
||
pRight
->
nodeType
==
TSQL_NODE_FUNC
)
{
// 12 + expr2
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// 12 + columnRight
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
p
d
ata
,
pRightInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
p
d
ata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
reverseCopy
(
p
D
ata
,
pRightInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
p
D
ata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
pRightInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// 12 + 12
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
s
->
_node
.
optr
);
_arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExpr
->
_node
.
optr
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
tfree
(
p
d
ata
);
tfree
(
p
D
ata
);
tfree
(
pLeftOutput
);
tfree
(
pRightOutput
);
}
...
...
src/query/inc/qAggMain.h
浏览文件 @
a52725f1
...
...
@@ -23,6 +23,7 @@ extern "C" {
#include "os.h"
#include "tname.h"
#include "texpr.h"
#include "taosdef.h"
#include "trpc.h"
#include "tvariant.h"
...
...
@@ -86,16 +87,6 @@ extern "C" {
// #define TSDB_FUNC_HLL 41
// #define TSDB_FUNC_MODE 42
#define TSDB_FUNC_FLAG_UDF 0x8000
#define TSDB_FUNC_FLAG_SCALAR 0x4000
#define TSDB_FUNC_IS_SCALAR(id) ((((id) & TSDB_FUNC_FLAG_UDF) == 0) && (((id) & TSDB_FUNC_FLAG_SCALAR) != 0))
#define TSDB_FUNC_SCALAR_INDEX(id) ((id) & ~TSDB_FUNC_FLAG_SCALAR)
///////////////////////////////////////////
// SCALAR FUNCTIONS
#define TSDB_FUNC_SCALAR_POW (TSDB_FUNC_FLAG_SCALAR | 0x0000)
#define TSDB_FUNC_SCALAR_LOG (TSDB_FUNC_FLAG_SCALAR | 0x0001)
#define TSDB_FUNC_SCALAR_MAX_NUM 2
#define TSDB_FUNCSTATE_SO 0x1u // single output
#define TSDB_FUNCSTATE_MO 0x2u // dynamic number of output, not multinumber of output e.g., TOP/BOTTOM
#define TSDB_FUNCSTATE_STREAM 0x4u // function avail for stream
...
...
src/query/src/qAggMain.c
浏览文件 @
a52725f1
...
...
@@ -3405,7 +3405,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
pCtx
->
size
;
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
arithmeticTre
eTraverse
(
sas
->
pExprInfo
->
pExpr
,
pCtx
->
size
,
pCtx
->
pOutput
,
sas
,
pCtx
->
order
,
getArithColumnData
);
exprTreeInternalNod
eTraverse
(
sas
->
pExprInfo
->
pExpr
,
pCtx
->
size
,
pCtx
->
pOutput
,
sas
,
pCtx
->
order
,
getArithColumnData
);
}
#define LIST_MINMAX_N(ctx, minOutput, maxOutput, elemCnt, data, type, tsdbType, numOfNotNullElem) \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录