Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06896e94
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
06896e94
编写于
5月 23, 2022
作者:
D
dapan1121
提交者:
GitHub
5月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12775 from taosdata/feature/3.0_constant
feat: support constant value as function param
上级
d1035938
0c22c548
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
270 addition
and
66 deletion
+270
-66
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+5
-4
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+5
-0
include/util/tdef.h
include/util/tdef.h
+1
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+23
-9
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+140
-15
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+7
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+22
-30
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+36
-5
source/libs/planner/test/planBasicTest.cpp
source/libs/planner/test/planBasicTest.cpp
+2
-0
source/libs/planner/test/planGroupByTest.cpp
source/libs/planner/test/planGroupByTest.cpp
+2
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+6
-1
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+18
-0
未找到文件。
include/libs/nodes/nodes.h
浏览文件 @
06896e94
...
...
@@ -59,10 +59,10 @@ extern "C" {
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
(NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
#define DESTORY_LIST(list) \
do { \
nodesDestroyList(
list
); \
list
= NULL; \
#define DESTORY_LIST(list)
\
do {
\
nodesDestroyList(
(list)
); \
(list)
= NULL; \
} while (0)
typedef
enum
ENodeType
{
...
...
@@ -96,6 +96,7 @@ typedef enum ENodeType {
QUERY_NODE_EXPLAIN_OPTIONS
,
QUERY_NODE_STREAM_OPTIONS
,
QUERY_NODE_TOPIC_OPTIONS
,
QUERY_NODE_LEFT_VALUE
,
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
,
...
...
include/libs/nodes/querynodes.h
浏览文件 @
06896e94
...
...
@@ -81,6 +81,7 @@ typedef struct SValueNode {
char
*
literal
;
bool
isDuration
;
bool
translate
;
bool
notReserved
;
int16_t
placeholderNo
;
union
{
bool
b
;
...
...
@@ -93,6 +94,10 @@ typedef struct SValueNode {
char
unit
;
}
SValueNode
;
typedef
struct
SLeftValueNode
{
ENodeType
type
;
}
SLeftValueNode
;
typedef
struct
SOperatorNode
{
SExprNode
node
;
// QUERY_NODE_OPERATOR
EOperatorType
opType
;
...
...
include/util/tdef.h
浏览文件 @
06896e94
...
...
@@ -132,6 +132,7 @@ typedef enum EOperatorType {
OP_TYPE_MOD
,
// unary arithmetic operator
OP_TYPE_MINUS
,
OP_TYPE_ASSIGN
,
// bit operator
OP_TYPE_BIT_AND
,
...
...
source/libs/function/src/builtins.c
浏览文件 @
06896e94
...
...
@@ -14,8 +14,8 @@
*/
#include "builtins.h"
#include "querynodes.h"
#include "builtinsimpl.h"
#include "querynodes.h"
#include "scalar.h"
#include "taoserror.h"
#include "tdatablock.h"
...
...
@@ -185,6 +185,19 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
if
(
!
IS_NUMERIC_TYPE
(
para1Type
)
||
!
IS_INTEGER_TYPE
(
para2Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SNode
*
pParamNode
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
if
(
nodeType
(
pParamNode
)
!=
QUERY_NODE_VALUE
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SValueNode
*
pValue
=
(
SValueNode
*
)
pParamNode
;
if
(
pValue
->
datum
.
i
<
0
||
pValue
->
datum
.
i
>
100
)
{
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pValue
->
notReserved
=
true
;
if
(
3
==
paraNum
)
{
SNode
*
pPara3
=
nodesListGetNode
(
pFunc
->
pParameterList
,
2
);
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pPara3
)
||
!
validAperventileAlgo
((
SValueNode
*
)
pPara3
))
{
...
...
@@ -215,7 +228,7 @@ static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SValueNode
*
pValue
=
(
SValueNode
*
)
pParamNode
;
SValueNode
*
pValue
=
(
SValueNode
*
)
pParamNode
;
if
(
pValue
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_BIGINT
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
...
...
@@ -224,6 +237,8 @@ static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pValue
->
notReserved
=
true
;
SDataType
*
pType
=
&
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
;
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pType
->
bytes
,
.
type
=
pType
->
type
};
return
TSDB_CODE_SUCCESS
;
...
...
@@ -336,7 +351,7 @@ static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
pFunc
->
node
.
resType
=
(
SDataType
)
{.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -361,7 +376,7 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
pFunc
->
node
.
resType
=
(
SDataType
)
{.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -392,7 +407,7 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
}
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
resType
].
bytes
,
.
type
=
resType
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
resType
].
bytes
,
.
type
=
resType
};
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -434,7 +449,7 @@ static int32_t translateSample(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
}
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
uint8_t
colType
=
pCol
->
resType
.
type
;
uint8_t
colType
=
pCol
->
resType
.
type
;
if
(
IS_VAR_DATA_TYPE
(
colType
))
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pCol
->
resType
.
bytes
,
.
type
=
colType
};
}
else
{
...
...
@@ -463,7 +478,7 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
}
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
uint8_t
colType
=
pCol
->
resType
.
type
;
uint8_t
colType
=
pCol
->
resType
.
type
;
if
(
IS_VAR_DATA_TYPE
(
colType
))
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pCol
->
resType
.
bytes
,
.
type
=
colType
};
}
else
{
...
...
@@ -500,8 +515,7 @@ static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The parameters of UNIQUE can only be columns"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The parameters of UNIQUE can only be columns"
);
}
pFunc
->
node
.
resType
=
((
SExprNode
*
)
pPara
)
->
resType
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
06896e94
...
...
@@ -19,6 +19,21 @@
#include "taos.h"
#include "taoserror.h"
#define COPY_SCALAR_FIELD(fldname) \
do { \
(pDst)->fldname = (pSrc)->fldname; \
} while (0)
#define COPY_CHAR_ARRAY_FIELD(fldname) \
do { \
strcpy((pDst)->fldname, (pSrc)->fldname); \
} while (0)
#define COPY_OBJECT_FIELD(fldname, size) \
do { \
memcpy(&((pDst)->fldname), &((pSrc)->fldname), size); \
} while (0)
#define COPY_CHAR_POINT_FIELD(fldname) \
do { \
if (NULL == (pSrc)->fldname) { \
...
...
@@ -70,27 +85,61 @@
} \
} while (0)
static
void
dataTypeCopy
(
const
SDataType
*
pSrc
,
SDataType
*
pDst
)
{}
static
SNode
*
exprNodeCopy
(
const
SExprNode
*
pSrc
,
SExprNode
*
pDst
)
{
dataTypeCopy
(
&
pSrc
->
resType
,
&
pDst
->
resType
);
pDst
->
pAssociation
=
NULL
;
COPY_OBJECT_FIELD
(
resType
,
sizeof
(
SDataType
));
COPY_CHAR_ARRAY_FIELD
(
aliasName
);
COPY_CHAR_ARRAY_FIELD
(
userAlias
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
columnNodeCopy
(
const
SColumnNode
*
pSrc
,
SColumnNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
pDst
->
pProjectRef
=
NULL
;
COPY_SCALAR_FIELD
(
tableId
);
COPY_SCALAR_FIELD
(
tableType
);
COPY_SCALAR_FIELD
(
colId
);
COPY_SCALAR_FIELD
(
colType
);
COPY_CHAR_ARRAY_FIELD
(
dbName
);
COPY_CHAR_ARRAY_FIELD
(
tableName
);
COPY_CHAR_ARRAY_FIELD
(
tableAlias
);
COPY_CHAR_ARRAY_FIELD
(
colName
);
COPY_SCALAR_FIELD
(
dataBlockId
);
COPY_SCALAR_FIELD
(
slotId
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
valueNodeCopy
(
const
SValueNode
*
pSrc
,
SValueNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
COPY_CHAR_POINT_FIELD
(
literal
);
COPY_SCALAR_FIELD
(
isDuration
);
COPY_SCALAR_FIELD
(
translate
);
COPY_SCALAR_FIELD
(
notReserved
);
COPY_SCALAR_FIELD
(
placeholderNo
);
COPY_SCALAR_FIELD
(
typeData
);
COPY_SCALAR_FIELD
(
unit
);
if
(
!
pSrc
->
translate
)
{
return
(
SNode
*
)
pDst
;
}
switch
(
pSrc
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
COPY_SCALAR_FIELD
(
datum
.
b
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
COPY_SCALAR_FIELD
(
datum
.
i
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
COPY_SCALAR_FIELD
(
datum
.
d
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
COPY_SCALAR_FIELD
(
datum
.
u
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
...
...
@@ -104,7 +153,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_BLOB
:
// todo
case
TSDB_DATA_TYPE_MEDIUMBLOB
:
default:
break
;
}
...
...
@@ -113,6 +162,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
static
SNode
*
operatorNodeCopy
(
const
SOperatorNode
*
pSrc
,
SOperatorNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
COPY_SCALAR_FIELD
(
opType
);
CLONE_NODE_FIELD
(
pLeft
);
CLONE_NODE_FIELD
(
pRight
);
return
(
SNode
*
)
pDst
;
...
...
@@ -120,18 +170,27 @@ static SNode* operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) {
static
SNode
*
logicConditionNodeCopy
(
const
SLogicConditionNode
*
pSrc
,
SLogicConditionNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
COPY_SCALAR_FIELD
(
condType
);
CLONE_NODE_LIST_FIELD
(
pParameterList
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
functionNodeCopy
(
const
SFunctionNode
*
pSrc
,
SFunctionNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
COPY_CHAR_ARRAY_FIELD
(
functionName
);
COPY_SCALAR_FIELD
(
funcId
);
COPY_SCALAR_FIELD
(
funcType
);
CLONE_NODE_LIST_FIELD
(
pParameterList
);
COPY_SCALAR_FIELD
(
udfBufSize
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
tableNodeCopy
(
const
STableNode
*
pSrc
,
STableNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
exprNodeCopy
);
COPY_CHAR_ARRAY_FIELD
(
dbName
);
COPY_CHAR_ARRAY_FIELD
(
tableName
);
COPY_CHAR_ARRAY_FIELD
(
tableAlias
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -159,6 +218,8 @@ static SNode* realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst
COPY_BASE_OBJECT_FIELD
(
table
,
tableNodeCopy
);
CLONE_OBJECT_FIELD
(
pMeta
,
tableMetaClone
);
CLONE_OBJECT_FIELD
(
pVgroupList
,
vgroupsInfoClone
);
COPY_CHAR_ARRAY_FIELD
(
qualDbName
);
COPY_SCALAR_FIELD
(
ratio
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -170,6 +231,7 @@ static SNode* tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst
static
SNode
*
joinTableNodeCopy
(
const
SJoinTableNode
*
pSrc
,
SJoinTableNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
table
,
tableNodeCopy
);
COPY_SCALAR_FIELD
(
joinType
);
CLONE_NODE_FIELD
(
pLeft
);
CLONE_NODE_FIELD
(
pRight
);
CLONE_NODE_FIELD
(
pOnCond
);
...
...
@@ -177,21 +239,30 @@ static SNode* joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst
}
static
SNode
*
targetNodeCopy
(
const
STargetNode
*
pSrc
,
STargetNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
COPY_SCALAR_FIELD
(
slotId
);
CLONE_NODE_FIELD
(
pExpr
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
groupingSetNodeCopy
(
const
SGroupingSetNode
*
pSrc
,
SGroupingSetNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
groupingSetType
);
CLONE_NODE_LIST_FIELD
(
pParameterList
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
orderByExprNodeCopy
(
const
SOrderByExprNode
*
pSrc
,
SOrderByExprNode
*
pDst
)
{
CLONE_NODE_FIELD
(
pExpr
);
COPY_SCALAR_FIELD
(
order
);
COPY_SCALAR_FIELD
(
nullOrder
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
limitNodeCopy
(
const
SLimitNode
*
pSrc
,
SLimitNode
*
pDst
)
{
return
(
SNode
*
)
pDst
;
}
static
SNode
*
limitNodeCopy
(
const
SLimitNode
*
pSrc
,
SLimitNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
limit
);
COPY_SCALAR_FIELD
(
offset
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
stateWindowNodeCopy
(
const
SStateWindowNode
*
pSrc
,
SStateWindowNode
*
pDst
)
{
CLONE_NODE_FIELD
(
pCol
);
...
...
@@ -215,13 +286,16 @@ static SNode* intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalW
}
static
SNode
*
nodeListNodeCopy
(
const
SNodeListNode
*
pSrc
,
SNodeListNode
*
pDst
)
{
COPY_OBJECT_FIELD
(
dataType
,
sizeof
(
SDataType
));
CLONE_NODE_LIST_FIELD
(
pNodeList
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
fillNodeCopy
(
const
SFillNode
*
pSrc
,
SFillNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
mode
);
CLONE_NODE_FIELD
(
pValues
);
CLONE_NODE_FIELD
(
pWStartTs
);
COPY_OBJECT_FIELD
(
timeRange
,
sizeof
(
STimeWindow
));
return
(
SNode
*
)
pDst
;
}
...
...
@@ -229,7 +303,7 @@ static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
CLONE_NODE_LIST_FIELD
(
pTargets
);
CLONE_NODE_FIELD
(
pConditions
);
CLONE_NODE_LIST_FIELD
(
pChildren
);
pDst
->
pParent
=
NULL
;
COPY_SCALAR_FIELD
(
optimizedFlag
)
;
return
(
SNode
*
)
pDst
;
}
...
...
@@ -239,12 +313,25 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
CLONE_NODE_LIST_FIELD
(
pScanPseudoCols
);
CLONE_OBJECT_FIELD
(
pMeta
,
tableMetaClone
);
CLONE_OBJECT_FIELD
(
pVgroupList
,
vgroupsInfoClone
);
COPY_SCALAR_FIELD
(
scanType
);
COPY_OBJECT_FIELD
(
scanSeq
[
0
],
sizeof
(
uint8_t
)
*
2
);
COPY_OBJECT_FIELD
(
scanRange
,
sizeof
(
STimeWindow
));
COPY_OBJECT_FIELD
(
tableName
,
sizeof
(
SName
));
COPY_SCALAR_FIELD
(
showRewrite
);
COPY_SCALAR_FIELD
(
ratio
);
CLONE_NODE_LIST_FIELD
(
pDynamicScanFuncs
);
COPY_SCALAR_FIELD
(
dataRequired
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
intervalUnit
);
COPY_SCALAR_FIELD
(
slidingUnit
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicJoinCopy
(
const
SJoinLogicNode
*
pSrc
,
SJoinLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
joinType
);
CLONE_NODE_FIELD
(
pOnConditions
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -259,32 +346,50 @@ static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
static
SNode
*
logicProjectCopy
(
const
SProjectLogicNode
*
pSrc
,
SProjectLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pProjections
);
COPY_CHAR_ARRAY_FIELD
(
stmtName
);
COPY_SCALAR_FIELD
(
limit
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
slimit
);
COPY_SCALAR_FIELD
(
soffset
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicVnodeModifCopy
(
const
SVnodeModifLogicNode
*
pSrc
,
SVnodeModifLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
pDst
->
pDataBlocks
=
NULL
;
pDst
->
pVgDataBlocks
=
NULL
;
COPY_SCALAR_FIELD
(
msgType
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicExchangeCopy
(
const
SExchangeLogicNode
*
pSrc
,
SExchangeLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
srcGroupId
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicWindowCopy
(
const
SWindowLogicNode
*
pSrc
,
SWindowLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
winType
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
intervalUnit
);
COPY_SCALAR_FIELD
(
slidingUnit
);
COPY_SCALAR_FIELD
(
sessionGap
);
CLONE_NODE_FIELD
(
pTspk
);
CLONE_NODE_FIELD
(
pStateExpr
);
COPY_SCALAR_FIELD
(
triggerType
);
COPY_SCALAR_FIELD
(
watermark
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicFillCopy
(
const
SFillLogicNode
*
pSrc
,
SFillLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
mode
);
CLONE_NODE_FIELD
(
pWStartTs
);
CLONE_NODE_FIELD
(
pValues
);
COPY_OBJECT_FIELD
(
timeRange
,
sizeof
(
STimeWindow
));
return
(
SNode
*
)
pDst
;
}
...
...
@@ -301,28 +406,41 @@ static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogi
}
static
SNode
*
logicSubplanCopy
(
const
SLogicSubplan
*
pSrc
,
SLogicSubplan
*
pDst
)
{
COPY_OBJECT_FIELD
(
id
,
sizeof
(
SSubplanId
));
CLONE_NODE_FIELD
(
pNode
);
pDst
->
pChildren
=
NULL
;
pDst
->
pParents
=
NULL
;
pDst
->
pVgroupList
=
NULL
;
COPY_SCALAR_FIELD
(
subplanType
)
;
COPY_SCALAR_FIELD
(
level
)
;
COPY_SCALAR_FIELD
(
splitFlag
)
;
return
(
SNode
*
)
pDst
;
}
static
SNode
*
dataBlockDescCopy
(
const
SDataBlockDescNode
*
pSrc
,
SDataBlockDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
CLONE_NODE_LIST_FIELD
(
pSlots
);
COPY_SCALAR_FIELD
(
totalRowSize
);
COPY_SCALAR_FIELD
(
outputRowSize
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
slotDescCopy
(
const
SSlotDescNode
*
pSrc
,
SSlotDescNode
*
pDst
)
{
dataTypeCopy
(
&
pSrc
->
dataType
,
&
pDst
->
dataType
);
COPY_SCALAR_FIELD
(
slotId
);
COPY_OBJECT_FIELD
(
dataType
,
sizeof
(
SDataType
));
COPY_SCALAR_FIELD
(
reserve
);
COPY_SCALAR_FIELD
(
output
);
COPY_SCALAR_FIELD
(
tag
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
downstreamSourceCopy
(
const
SDownstreamSourceNode
*
pSrc
,
SDownstreamSourceNode
*
pDst
)
{
COPY_OBJECT_FIELD
(
addr
,
sizeof
(
SQueryNodeAddr
));
COPY_SCALAR_FIELD
(
taskId
);
COPY_SCALAR_FIELD
(
schedId
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
selectStmtCopy
(
const
SSelectStmt
*
pSrc
,
SSelectStmt
*
pDst
)
{
COPY_SCALAR_FIELD
(
isDistinct
);
CLONE_NODE_LIST_FIELD
(
pProjectionList
);
CLONE_NODE_FIELD
(
pFromTable
);
CLONE_NODE_FIELD
(
pWhere
);
...
...
@@ -333,6 +451,12 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
CLONE_NODE_LIST_FIELD
(
pOrderByList
);
CLONE_NODE_FIELD
(
pLimit
);
CLONE_NODE_FIELD
(
pLimit
);
COPY_CHAR_ARRAY_FIELD
(
stmtName
);
COPY_SCALAR_FIELD
(
precision
);
COPY_SCALAR_FIELD
(
isEmptyResult
);
COPY_SCALAR_FIELD
(
isTimeOrderQuery
);
COPY_SCALAR_FIELD
(
hasAggFuncs
);
COPY_SCALAR_FIELD
(
hasRepeatScanFuncs
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -345,7 +469,6 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
memcpy
(
pDst
,
pNode
,
nodesNodeSize
(
nodeType
(
pNode
)));
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
return
columnNodeCopy
((
const
SColumnNode
*
)
pNode
,
(
SColumnNode
*
)
pDst
);
...
...
@@ -387,6 +510,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
slotDescCopy
((
const
SSlotDescNode
*
)
pNode
,
(
SSlotDescNode
*
)
pDst
);
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
downstreamSourceCopy
((
const
SDownstreamSourceNode
*
)
pNode
,
(
SDownstreamSourceNode
*
)
pDst
);
case
QUERY_NODE_LEFT_VALUE
:
return
pDst
;
case
QUERY_NODE_SELECT_STMT
:
return
selectStmtCopy
((
const
SSelectStmt
*
)
pNode
,
(
SSelectStmt
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
06896e94
...
...
@@ -78,6 +78,8 @@ const char* nodesNodeName(ENodeType type) {
return
"TableOptions"
;
case
QUERY_NODE_INDEX_OPTIONS
:
return
"IndexOptions"
;
case
QUERY_NODE_LEFT_VALUE
:
return
"LeftValue"
;
case
QUERY_NODE_SET_OPERATOR
:
return
"SetOperator"
;
case
QUERY_NODE_SELECT_STMT
:
...
...
@@ -2175,7 +2177,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
}
varDataSetLen
(
pNode
->
datum
.
p
,
pNode
->
node
.
resType
.
bytes
);
varDataSetLen
(
pNode
->
datum
.
p
,
pNode
->
node
.
resType
.
bytes
-
VARSTR_HEADER_SIZE
);
if
(
TSDB_DATA_TYPE_NCHAR
==
pNode
->
node
.
resType
.
type
)
{
char
*
buf
=
taosMemoryCalloc
(
1
,
pNode
->
node
.
resType
.
bytes
*
2
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
buf
)
{
...
...
@@ -3019,6 +3021,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
break
;
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
downstreamSourceNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LEFT_VALUE
:
return
TSDB_CODE_SUCCESS
;
// SLeftValueNode has no fields to serialize.
case
QUERY_NODE_SET_OPERATOR
:
return
setOperatorToJson
(
pObj
,
pJson
);
case
QUERY_NODE_SELECT_STMT
:
...
...
@@ -3130,6 +3134,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToSlotDescNode
(
pJson
,
pObj
);
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
jsonToDownstreamSourceNode
(
pJson
,
pObj
);
case
QUERY_NODE_LEFT_VALUE
:
return
TSDB_CODE_SUCCESS
;
// SLeftValueNode has no fields to deserialize.
case
QUERY_NODE_SET_OPERATOR
:
return
jsonToSetOperator
(
pJson
,
pObj
);
case
QUERY_NODE_SELECT_STMT
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
06896e94
...
...
@@ -79,6 +79,8 @@ int32_t nodesNodeSize(ENodeType type) {
return
sizeof
(
SStreamOptions
);
case
QUERY_NODE_TOPIC_OPTIONS
:
return
sizeof
(
STopicOptions
);
case
QUERY_NODE_LEFT_VALUE
:
return
sizeof
(
SLeftValueNode
);
case
QUERY_NODE_SET_OPERATOR
:
return
sizeof
(
SSetOperator
);
case
QUERY_NODE_SELECT_STMT
:
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
06896e94
...
...
@@ -646,12 +646,13 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
}
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
targetDt
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
targetDt
.
bytes
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
}
varDataSetLen
(
pVal
->
datum
.
p
,
targetDt
.
bytes
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
targetDt
.
bytes
);
int32_t
len
=
TMIN
(
targetDt
.
bytes
-
VARSTR_HEADER_SIZE
,
pVal
->
node
.
resType
.
bytes
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
len
);
break
;
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
...
...
@@ -662,19 +663,18 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
{
int32_t
bytes
=
targetDt
.
bytes
*
TSDB_NCHAR_SIZE
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
bytes
+
VARSTR_HEADER_SIZE
+
1
);
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
targetDt
.
bytes
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
;
}
int32_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
pVal
->
literal
,
pVal
->
node
.
resType
.
bytes
,
(
TdUcs4
*
)
varDataVal
(
pVal
->
datum
.
p
),
bytes
,
&
output
))
{
int32_t
len
=
0
;
if
(
!
taosMbsToUcs4
(
pVal
->
literal
,
pVal
->
node
.
resType
.
bytes
,
(
TdUcs4
*
)
varDataVal
(
pVal
->
datum
.
p
),
targetDt
.
bytes
-
VARSTR_HEADER_SIZE
,
&
len
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
varDataSetLen
(
pVal
->
datum
.
p
,
output
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
break
;
}
case
TSDB_DATA_TYPE_JSON
:
...
...
@@ -690,8 +690,20 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
return
DEAL_RES_CONTINUE
;
}
static
int32_t
calcTypeBytes
(
SDataType
dt
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
dt
.
type
)
{
return
dt
.
bytes
+
VARSTR_HEADER_SIZE
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
return
dt
.
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
else
{
return
dt
.
bytes
;
}
}
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
return
translateValueImpl
(
pCxt
,
pVal
,
pVal
->
node
.
resType
);
SDataType
dt
=
pVal
->
node
.
resType
;
dt
.
bytes
=
calcTypeBytes
(
dt
);
return
translateValueImpl
(
pCxt
,
pVal
,
dt
);
}
static
bool
isMultiResFunc
(
SNode
*
pNode
)
{
...
...
@@ -2343,16 +2355,6 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
return
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_DB
,
(
FSerializeFunc
)
tSerializeSAlterDbReq
,
&
alterReq
);
}
static
int32_t
calcTypeBytes
(
SDataType
dt
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
dt
.
type
)
{
return
dt
.
bytes
+
VARSTR_HEADER_SIZE
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
return
dt
.
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
else
{
return
dt
.
bytes
;
}
}
static
int32_t
columnDefNodeToField
(
SNodeList
*
pList
,
SArray
**
pArray
)
{
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pList
),
sizeof
(
SField
));
SNode
*
pNode
;
...
...
@@ -4088,18 +4090,8 @@ static int32_t createValueFromFunction(STranslateContext* pCxt, SFunctionNode* p
return
scalarCalculateConstants
((
SNode
*
)
pFunc
,
(
SNode
**
)
pVal
);
}
static
int32_t
colDataBytesToValueDataBytes
(
uint8_t
type
,
int32_t
bytes
)
{
if
(
TSDB_DATA_TYPE_VARCHAR
==
type
||
TSDB_DATA_TYPE_BINARY
==
type
||
TSDB_DATA_TYPE_VARBINARY
==
type
)
{
return
bytes
-
VARSTR_HEADER_SIZE
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
type
)
{
return
(
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
;
}
return
bytes
;
}
static
SDataType
schemaToDataType
(
SSchema
*
pSchema
)
{
SDataType
dt
=
{.
type
=
pSchema
->
type
,
.
bytes
=
pSchema
->
bytes
,
.
precision
=
0
,
.
scale
=
0
};
dt
.
bytes
=
colDataBytesToValueDataBytes
(
pSchema
->
type
,
pSchema
->
bytes
);
return
dt
;
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
06896e94
...
...
@@ -599,14 +599,17 @@ typedef struct SRewritePrecalcExprsCxt {
static
EDealRes
collectAndRewrite
(
SRewritePrecalcExprsCxt
*
pCxt
,
SNode
**
pNode
)
{
SNode
*
pExpr
=
nodesCloneNode
(
*
pNode
);
if
(
NULL
==
pExpr
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
if
(
nodesListAppend
(
pCxt
->
pPrecalcExprs
,
pExpr
))
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
nodesDestroyNode
(
pExpr
);
return
DEAL_RES_ERROR
;
}
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
nodesDestroyNode
(
pExpr
);
return
DEAL_RES_ERROR
;
}
...
...
@@ -624,16 +627,45 @@ static EDealRes collectAndRewrite(SRewritePrecalcExprsCxt* pCxt, SNode** pNode)
return
DEAL_RES_IGNORE_CHILD
;
}
static
int32_t
rewriteValueToOperator
(
SRewritePrecalcExprsCxt
*
pCxt
,
SNode
**
pNode
)
{
SOperatorNode
*
pOper
=
(
SOperatorNode
*
)
nodesMakeNode
(
QUERY_NODE_OPERATOR
);
if
(
NULL
==
pOper
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pOper
->
pLeft
=
nodesMakeNode
(
QUERY_NODE_LEFT_VALUE
);
if
(
NULL
==
pOper
->
pLeft
)
{
nodesDestroyNode
(
pOper
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SValueNode
*
pVal
=
(
SValueNode
*
)
*
pNode
;
pOper
->
node
.
resType
=
pVal
->
node
.
resType
;
strcpy
(
pOper
->
node
.
aliasName
,
pVal
->
node
.
aliasName
);
pOper
->
opType
=
OP_TYPE_ASSIGN
;
pOper
->
pRight
=
*
pNode
;
*
pNode
=
(
SNode
*
)
pOper
;
return
TSDB_CODE_SUCCESS
;
}
static
EDealRes
doRewritePrecalcExprs
(
SNode
**
pNode
,
void
*
pContext
)
{
SRewritePrecalcExprsCxt
*
pCxt
=
(
SRewritePrecalcExprsCxt
*
)
pContext
;
switch
(
nodeType
(
*
pNode
))
{
case
QUERY_NODE_VALUE
:
{
if
(((
SValueNode
*
)
*
pNode
)
->
notReserved
)
{
break
;
}
pCxt
->
errCode
=
rewriteValueToOperator
(
pCxt
,
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
pCxt
->
errCode
)
{
return
DEAL_RES_ERROR
;
}
return
collectAndRewrite
(
pCxt
,
pNode
);
}
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
{
return
collectAndRewrite
(
pC
onte
xt
,
pNode
);
return
collectAndRewrite
(
pCxt
,
pNode
);
}
case
QUERY_NODE_FUNCTION
:
{
if
(
fmIsScalarFunc
(((
SFunctionNode
*
)(
*
pNode
))
->
funcId
))
{
return
collectAndRewrite
(
pC
onte
xt
,
pNode
);
return
collectAndRewrite
(
pCxt
,
pNode
);
}
}
default:
...
...
@@ -677,9 +709,8 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN
}
SRewritePrecalcExprsCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pPrecalcExprs
=
*
pPrecalcExprs
};
nodesRewriteExprs
(
*
pRewrittenList
,
doRewritePrecalcExprs
,
&
cxt
);
if
(
0
==
LIST_LENGTH
(
cxt
.
pPrecalcExprs
))
{
nodesDestroyList
(
cxt
.
pPrecalcExprs
);
*
pPrecalcExprs
=
NULL
;
if
(
0
==
LIST_LENGTH
(
cxt
.
pPrecalcExprs
)
||
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
DESTORY_LIST
(
*
pPrecalcExprs
);
}
return
cxt
.
errCode
;
}
...
...
source/libs/planner/test/planBasicTest.cpp
浏览文件 @
06896e94
...
...
@@ -50,4 +50,6 @@ TEST_F(PlanBasicTest, func) {
run
(
"SELECT DIFF(c1) FROM t1"
);
run
(
"SELECT PERCENTILE(c1, 60) FROM t1"
);
run
(
"SELECT TOP(c1, 60) FROM t1"
);
}
source/libs/planner/test/planGroupByTest.cpp
浏览文件 @
06896e94
...
...
@@ -49,6 +49,8 @@ TEST_F(PlanGroupByTest, aggFunc) {
run
(
"SELECT LAST(*), FIRST(*) FROM t1"
);
run
(
"SELECT LAST(*), FIRST(*) FROM t1 GROUP BY c1"
);
run
(
"SELECT SUM(10), COUNT(c1) FROM t1 GROUP BY c2"
);
}
TEST_F
(
PlanGroupByTest
,
selectFunc
)
{
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
06896e94
...
...
@@ -182,6 +182,11 @@ int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) {
int32_t
sclInitParam
(
SNode
*
node
,
SScalarParam
*
param
,
SScalarCtx
*
ctx
,
int32_t
*
rowNum
)
{
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_LEFT_VALUE
:
{
SSDataBlock
*
pb
=
taosArrayGetP
(
ctx
->
pBlockList
,
0
);
param
->
numOfRows
=
pb
->
info
.
rows
;
break
;
}
case
QUERY_NODE_VALUE
:
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
;
...
...
@@ -845,7 +850,7 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) {
}
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
QUERY_NODE_LEFT_VALUE
==
nodeType
(
pNode
)
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
06896e94
...
...
@@ -824,7 +824,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
//for constant conversion, need to set proper length of pOutput description
if
(
len
<
outputLen
)
{
pOutput
->
columnData
->
info
.
bytes
=
len
;
pOutput
->
columnData
->
info
.
bytes
=
len
+
VARSTR_HEADER_SIZE
;
}
break
;
}
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
06896e94
...
...
@@ -1333,6 +1333,22 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
doReleaseVec
(
pLeftCol
,
leftConvert
);
}
void
vectorAssign
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
pLeft
->
numOfRows
;
if
(
colDataIsNull_s
(
pRight
->
columnData
,
0
))
{
for
(
int32_t
i
=
0
;
i
<
pOut
->
numOfRows
;
++
i
)
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
pOut
->
numOfRows
;
++
i
)
{
colDataAppend
(
pOutputCol
,
i
,
colDataGetData
(
pRight
->
columnData
,
0
),
false
);
}
}
}
void
vectorConcat
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
#if 0
int32_t len = pLeft->bytes + pRight->bytes;
...
...
@@ -1691,6 +1707,8 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
return
vectorMathRemainder
;
case
OP_TYPE_MINUS
:
return
vectorMathMinus
;
case
OP_TYPE_ASSIGN
:
return
vectorAssign
;
case
OP_TYPE_GREATER_THAN
:
return
vectorGreater
;
case
OP_TYPE_GREATER_EQUAL
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录