Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
49143d07
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,发现更多精彩内容 >>
提交
49143d07
编写于
2月 24, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-13495 physical plan refactoring
上级
5fa4b1ae
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
321 addition
and
156 deletion
+321
-156
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+3
-2
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+14
-2
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+9
-7
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+0
-10
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+0
-26
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+4
-2
source/libs/planner/src/plannerImpl.c
source/libs/planner/src/plannerImpl.c
+266
-84
source/libs/planner/test/newPlannerTest.cpp
source/libs/planner/test/newPlannerTest.cpp
+2
-2
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+6
-6
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+11
-11
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+6
-4
未找到文件。
include/libs/nodes/nodes.h
浏览文件 @
49143d07
...
...
@@ -62,7 +62,6 @@ typedef enum ENodeType {
QUERY_NODE_NODE_LIST
,
QUERY_NODE_FILL
,
QUERY_NODE_RAW_EXPR
,
// Only be used in parser module.
QUERY_NODE_COLUMN_REF
,
QUERY_NODE_TARGET
,
QUERY_NODE_TUPLE_DESC
,
QUERY_NODE_SLOT_DESC
,
...
...
@@ -81,7 +80,9 @@ typedef enum ENodeType {
// physical plan node
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
,
QUERY_NODE_PHYSICAL_PLAN_PROJECT
QUERY_NODE_PHYSICAL_PLAN_PROJECT
,
QUERY_NODE_PHYSICAL_PLAN_JOIN
,
QUERY_NODE_PHYSICAL_PLAN_AGG
}
ENodeType
;
/**
...
...
include/libs/nodes/plannodes.h
浏览文件 @
49143d07
...
...
@@ -69,8 +69,6 @@ typedef struct SSlotDescNode {
ENodeType
type
;
int16_t
slotId
;
SDataType
dataType
;
int16_t
srcTupleId
;
int16_t
srcSlotId
;
bool
reserve
;
bool
output
;
}
SSlotDescNode
;
...
...
@@ -115,6 +113,20 @@ typedef struct SProjectPhysiNode {
SNodeList
*
pProjections
;
}
SProjectPhysiNode
;
typedef
struct
SJoinPhysiNode
{
SPhysiNode
node
;
EJoinType
joinType
;
SNode
*
pOnConditions
;
// in or out tuple ?
SNodeList
*
pTargets
;
}
SJoinPhysiNode
;
typedef
struct
SAggPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of group_by_clause and parameter expression of aggregate function
SNodeList
*
pGroupKeys
;
// SColumnRefNode list
SNodeList
*
pAggFuncs
;
}
SAggPhysiNode
;
#ifdef __cplusplus
}
#endif
...
...
include/libs/nodes/querynodes.h
浏览文件 @
49143d07
...
...
@@ -58,15 +58,17 @@ typedef struct SColumnNode {
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
SNode
*
pProjectRef
;
}
SColumnNode
;
typedef
struct
SColumnRefNode
{
ENodeType
type
;
SDataType
dataType
;
int16_t
tupleId
;
int16_t
slotId
;
int16_t
columnId
;
}
SColumnRefNode
;
}
SColumnNode
;
// typedef struct SColumnRefNode {
// ENodeType type;
// SDataType dataType;
// int16_t tupleId;
// int16_t slotId;
// int16_t columnId;
// } SColumnRefNode;
typedef
struct
STargetNode
{
ENodeType
type
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
49143d07
...
...
@@ -142,14 +142,6 @@ static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) {
return
(
SNode
*
)
pDst
;
}
static
SNode
*
columnRefNodeCopy
(
const
SColumnRefNode
*
pSrc
,
SColumnRefNode
*
pDst
)
{
dataTypeCopy
(
&
pSrc
->
dataType
,
&
pDst
->
dataType
);
COPY_SCALAR_FIELD
(
tupleId
);
COPY_SCALAR_FIELD
(
slotId
);
COPY_SCALAR_FIELD
(
columnId
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
targetNodeCopy
(
const
STargetNode
*
pSrc
,
STargetNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
tupleId
);
COPY_SCALAR_FIELD
(
slotId
);
...
...
@@ -183,8 +175,6 @@ SNode* nodesCloneNode(const SNode* pNode) {
return
logicConditionNodeCopy
((
const
SLogicConditionNode
*
)
pNode
,
(
SLogicConditionNode
*
)
pDst
);
case
QUERY_NODE_FUNCTION
:
return
functionNodeCopy
((
const
SFunctionNode
*
)
pNode
,
(
SFunctionNode
*
)
pDst
);
case
QUERY_NODE_COLUMN_REF
:
return
columnRefNodeCopy
((
const
SColumnRefNode
*
)
pNode
,
(
SColumnRefNode
*
)
pDst
);
case
QUERY_NODE_TARGET
:
return
targetNodeCopy
((
const
STargetNode
*
)
pNode
,
(
STargetNode
*
)
pDst
);
case
QUERY_NODE_REAL_TABLE
:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
49143d07
...
...
@@ -55,8 +55,6 @@ static char* nodeName(ENodeType type) {
return
"NodeList"
;
case
QUERY_NODE_FILL
:
return
"Fill"
;
case
QUERY_NODE_COLUMN_REF
:
return
"ColumnRef"
;
case
QUERY_NODE_TARGET
:
return
"Target"
;
case
QUERY_NODE_RAW_EXPR
:
...
...
@@ -503,28 +501,6 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
return
code
;
}
static
const
char
*
jkColumnRefDataType
=
"DataType"
;
static
const
char
*
jkColumnRefTupleId
=
"TupleId"
;
static
const
char
*
jkColumnRefSlotId
=
"SlotId"
;
static
const
char
*
jkColumnRefColumnId
=
"ColumnId"
;
static
int32_t
columnRefNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SColumnRefNode
*
pNode
=
(
const
SColumnRefNode
*
)
pObj
;
int32_t
code
=
tjsonAddObject
(
pJson
,
jkColumnRefDataType
,
dataTypeToJson
,
&
pNode
->
dataType
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkColumnRefTupleId
,
pNode
->
tupleId
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkColumnRefSlotId
,
pNode
->
slotId
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkColumnRefColumnId
,
pNode
->
columnId
);
}
return
code
;
}
static
const
char
*
jkTargetTupleId
=
"TupleId"
;
static
const
char
*
jkTargetSlotId
=
"SlotId"
;
static
const
char
*
jkTargetExpr
=
"Expr"
;
...
...
@@ -646,8 +622,6 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_INTERVAL_WINDOW
:
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_FILL
:
case
QUERY_NODE_COLUMN_REF
:
return
columnRefNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_TARGET
:
return
targetNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_RAW_EXPR
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
49143d07
...
...
@@ -79,8 +79,6 @@ SNode* nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SAggLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
return
makeNode
(
type
,
sizeof
(
SProjectLogicNode
));
case
QUERY_NODE_COLUMN_REF
:
return
makeNode
(
type
,
sizeof
(
SColumnRefNode
));
case
QUERY_NODE_TARGET
:
return
makeNode
(
type
,
sizeof
(
STargetNode
));
case
QUERY_NODE_TUPLE_DESC
:
...
...
@@ -93,6 +91,10 @@ SNode* nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
STableScanPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
return
makeNode
(
type
,
sizeof
(
SProjectPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
return
makeNode
(
type
,
sizeof
(
SJoinPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
return
makeNode
(
type
,
sizeof
(
SAggPhysiNode
));
default:
break
;
}
...
...
source/libs/planner/src/plannerImpl.c
浏览文件 @
49143d07
此差异已折叠。
点击以展开。
source/libs/planner/test/newPlannerTest.cpp
浏览文件 @
49143d07
...
...
@@ -123,8 +123,8 @@ TEST_F(NewPlannerTest, simple) {
TEST_F
(
NewPlannerTest
,
groupBy
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT count(*) FROM t1"
);
ASSERT_TRUE
(
run
());
//
bind("SELECT count(*) FROM t1");
//
ASSERT_TRUE(run());
bind
(
"SELECT c1, count(*) FROM t1 GROUP BY c1"
);
ASSERT_TRUE
(
run
());
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
49143d07
...
...
@@ -307,12 +307,12 @@ typedef struct SFilterInfo {
#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx]))
#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx]))
#define FILTER_GET_COL_FIELD_TYPE(fi) (((SColumn
RefNode *)((fi)->desc))->data
Type.type)
#define FILTER_GET_COL_FIELD_SIZE(fi) (((SColumn
RefNode *)((fi)->desc))->data
Type.bytes)
#define FILTER_GET_COL_FIELD_ID(fi) (((SColumn
RefNode *)((fi)->desc))->column
Id)
#define FILTER_GET_COL_FIELD_SLOT_ID(fi) (((SColumn
Ref
Node *)((fi)->desc))->slotId)
#define FILTER_GET_COL_FIELD_DESC(fi) ((SColumn
Ref
Node *)((fi)->desc))
#define FILTER_GET_COL_FIELD_DATA(fi, ri) ((char *)(fi)->data + ((SColumn
RefNode *)((fi)->desc))->data
Type.bytes * (ri))
#define FILTER_GET_COL_FIELD_TYPE(fi) (((SColumn
Node *)((fi)->desc))->node.res
Type.type)
#define FILTER_GET_COL_FIELD_SIZE(fi) (((SColumn
Node *)((fi)->desc))->node.res
Type.bytes)
#define FILTER_GET_COL_FIELD_ID(fi) (((SColumn
Node *)((fi)->desc))->col
Id)
#define FILTER_GET_COL_FIELD_SLOT_ID(fi) (((SColumnNode *)((fi)->desc))->slotId)
#define FILTER_GET_COL_FIELD_DESC(fi) ((SColumnNode *)((fi)->desc))
#define FILTER_GET_COL_FIELD_DATA(fi, ri) ((char *)(fi)->data + ((SColumn
Node *)((fi)->desc))->node.res
Type.bytes * (ri))
#define FILTER_GET_VAL_FIELD_TYPE(fi) (((SValueNode *)((fi)->desc))->node.resType.type)
#define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data)
#define FILTER_GET_JSON_VAL_FIELD_DATA(fi) ((char *)(fi)->desc)
...
...
source/libs/scalar/src/filter.c
浏览文件 @
49143d07
...
...
@@ -886,14 +886,14 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
nodeType
(
node
)
!=
QUERY_NODE_COLUMN
_REF
&&
nodeType
(
node
)
!=
QUERY_NODE_VALUE
)
{
if
(
nodeType
(
node
)
!=
QUERY_NODE_COLUMN
&&
nodeType
(
node
)
!=
QUERY_NODE_VALUE
)
{
FLT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
int32_t
type
;
void
*
v
;
if
(
nodeType
(
node
)
==
QUERY_NODE_COLUMN
_REF
)
{
if
(
nodeType
(
node
)
==
QUERY_NODE_COLUMN
)
{
type
=
FLD_TYPE_COLUMN
;
v
=
node
;
}
else
{
...
...
@@ -1418,7 +1418,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
qDebug
(
"COLUMN Field Num:%u"
,
info
->
fields
[
FLD_TYPE_COLUMN
].
num
);
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
++
i
)
{
SFilterField
*
field
=
&
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
];
SColumn
RefNode
*
refNode
=
(
SColumnRef
Node
*
)
field
->
desc
;
SColumn
Node
*
refNode
=
(
SColumn
Node
*
)
field
->
desc
;
qDebug
(
"COL%d => [%d][%d]"
,
i
,
refNode
->
tupleId
,
refNode
->
slotId
);
}
...
...
@@ -1447,7 +1447,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
char
str
[
512
]
=
{
0
};
SFilterField
*
left
=
FILTER_UNIT_LEFT_FIELD
(
info
,
unit
);
SColumn
RefNode
*
refNode
=
(
SColumnRef
Node
*
)
left
->
desc
;
SColumn
Node
*
refNode
=
(
SColumn
Node
*
)
left
->
desc
;
if
(
unit
->
compare
.
optr
>=
TSDB_RELATION_INVALID
&&
unit
->
compare
.
optr
<=
TSDB_RELATION_NMATCH
){
len
=
sprintf
(
str
,
"UNIT[%d] => [%d][%d] %s ["
,
i
,
refNode
->
tupleId
,
refNode
->
slotId
,
gOptrStr
[
unit
->
compare
.
optr
].
str
);
}
...
...
@@ -3549,17 +3549,17 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_ERROR
;
}
if
(
QUERY_NODE_COLUMN
_REF
!=
nodeType
(
node
->
pLeft
))
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pLeft
))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
}
else
{
if
((
QUERY_NODE_COLUMN
_REF
!=
nodeType
(
node
->
pLeft
))
&&
(
QUERY_NODE_VALUE
!=
nodeType
(
node
->
pLeft
)))
{
if
((
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pLeft
))
&&
(
QUERY_NODE_VALUE
!=
nodeType
(
node
->
pLeft
)))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
((
QUERY_NODE_COLUMN
_REF
!=
nodeType
(
node
->
pRight
))
&&
(
QUERY_NODE_VALUE
!=
nodeType
(
node
->
pRight
)))
{
if
((
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pRight
))
&&
(
QUERY_NODE_VALUE
!=
nodeType
(
node
->
pRight
)))
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3569,7 +3569,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
QUERY_NODE_COLUMN
_REF
!=
nodeType
(
node
->
pLeft
))
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
node
->
pLeft
))
{
SNode
*
t
=
node
->
pLeft
;
node
->
pLeft
=
node
->
pRight
;
node
->
pRight
=
t
;
...
...
@@ -3582,10 +3582,10 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
}
if
(
OP_TYPE_IN
!=
node
->
opType
)
{
SColumn
RefNode
*
refNode
=
(
SColumnRef
Node
*
)
node
->
pLeft
;
SColumn
Node
*
refNode
=
(
SColumn
Node
*
)
node
->
pLeft
;
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pRight
;
int32_t
type
=
vectorGetConvertType
(
refNode
->
data
Type
.
type
,
valueNode
->
node
.
resType
.
type
);
if
(
0
!=
type
&&
type
!=
refNode
->
data
Type
.
type
)
{
int32_t
type
=
vectorGetConvertType
(
refNode
->
node
.
res
Type
.
type
,
valueNode
->
node
.
resType
.
type
);
if
(
0
!=
type
&&
type
!=
refNode
->
node
.
res
Type
.
type
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
49143d07
...
...
@@ -50,13 +50,13 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
//TODO BUILD HASH
break
;
}
case
QUERY_NODE_COLUMN
_REF
:
{
case
QUERY_NODE_COLUMN
:
{
if
(
NULL
==
ctx
)
{
sclError
(
"invalid node type for constant calculating, type:%d, ctx:%p"
,
nodeType
(
node
),
ctx
);
SCL_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
SColumn
RefNode
*
ref
=
(
SColumnRef
Node
*
)
node
;
SColumn
Node
*
ref
=
(
SColumn
Node
*
)
node
;
if
(
ref
->
slotId
>=
taosArrayGetSize
(
ctx
->
pSrc
->
pDataBlock
))
{
sclError
(
"column ref slotId is too big, slodId:%d, dataBlockSize:%d"
,
ref
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pSrc
->
pDataBlock
));
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
...
...
@@ -190,7 +190,8 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu
SScalarFuncExecFuncs
ffpSet
=
{
0
};
int32_t
code
=
fmGetScalarFuncExecFuncs
(
node
->
funcId
,
&
ffpSet
);
if
(
code
)
{
sclError
(
"fmGetFuncExecFuncs failed, funcId:%d, code:%s"
,
node
->
funcId
,
tstrerror
(
code
));
sclError
(
"fmGetFuncExecFuncs failed, funcId:%d, code:%s"
,
node
->
funcId
,
tstrerror
(
code
));
SCL_ERR_RET
(
code
);
}
...
...
@@ -208,7 +209,8 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
code
=
(
*
ffpSet
.
process
)(
params
,
node
->
pParameterList
->
length
,
output
);
if
(
code
)
{
sclError
(
"scalar function exec failed, funcId:%d, code:%s"
,
node
->
funcId
,
tstrerror
(
code
));
sclError
(
"scalar function exec failed, funcId:%d, code:%s"
,
node
->
funcId
,
tstrerror
(
code
));
SCL_ERR_JRET
(
code
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录