Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
576e3d11
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看板
提交
576e3d11
编写于
6月 08, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: erase duplicated func node for window logic node
上级
bcac24b6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
21 deletion
+23
-21
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+19
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+3
-20
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
576e3d11
...
...
@@ -4940,7 +4940,7 @@ static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) {
}
snprintf
(
pTable
->
table
.
dbName
,
sizeof
(
pTable
->
table
.
dbName
),
"%s"
,
pInfo
->
pDbName
);
snprintf
(
pTable
->
table
.
tableName
,
sizeof
(
pTable
->
table
.
tableName
),
"%s"
,
pInfo
->
pTableName
);
snprintf
(
pTable
->
table
.
tableAlias
,
sizeof
(
pTable
->
table
.
table
Name
),
"%s"
,
pInfo
->
pTableName
);
snprintf
(
pTable
->
table
.
tableAlias
,
sizeof
(
pTable
->
table
.
table
Alias
),
"%s"
,
pInfo
->
pTableName
);
TSWAP
(
pTable
->
pMeta
,
pInfo
->
pRollupTableMeta
);
*
pOutput
=
(
SNode
*
)
pTable
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
576e3d11
...
...
@@ -749,6 +749,25 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
code
=
rewriteExprsForSelect
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
);
}
// erase duplicated funcNode by filtering colNode in pSelect->pProjectionList
int32_t
funcIndex
=
0
;
SNode
*
pFunc
=
NULL
,
*
pProject
=
NULL
;
FOREACH
(
pFunc
,
pWindow
->
pFuncs
)
{
bool
exist
=
false
;
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
if
(
0
!=
((
SFunctionNode
*
)
pFunc
)
->
node
.
aliasName
[
0
]
&&
0
==
strncmp
(((
SFunctionNode
*
)
pFunc
)
->
node
.
aliasName
,
((
SColumnNode
*
)
pProject
)
->
colName
,
TSDB_COL_NAME_LEN
))
{
exist
=
true
;
break
;
}
}
if
(
!
exist
)
{
nodesListErase
(
pWindow
->
pFuncs
,
nodesListGetCell
(
pWindow
->
pFuncs
,
funcIndex
));
}
else
{
++
funcIndex
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExprs
(
pWindow
->
pFuncs
,
&
pWindow
->
node
.
pTargets
);
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
576e3d11
...
...
@@ -1385,18 +1385,7 @@ static SNode* smaIndexOptFindWStartFunc(SNodeList* pSmaFuncs) {
return
NULL
;
}
static
SNode
*
smaIndexOptFuncInProject
(
SNodeList
*
pProjects
,
SFunctionNode
*
pFunc
)
{
SNode
*
pProject
=
NULL
;
FOREACH
(
pProject
,
pProjects
)
{
if
(
0
!=
pFunc
->
node
.
aliasName
[
0
]
&&
0
==
strncmp
(
pFunc
->
node
.
aliasName
,
((
SColumnNode
*
)
pProject
)
->
colName
,
TSDB_COL_NAME_LEN
))
{
return
pProject
;
}
}
return
NULL
;
}
static
int32_t
smaIndexOptCreateSmaCols
(
SWindowLogicNode
*
pWindow
,
uint64_t
tableId
,
SNodeList
*
pSmaFuncs
,
static
int32_t
smaIndexOptCreateSmaCols
(
SNodeList
*
pFuncs
,
uint64_t
tableId
,
SNodeList
*
pSmaFuncs
,
SNodeList
**
pOutput
)
{
SNodeList
*
pCols
=
NULL
;
SNode
*
pFunc
=
NULL
;
...
...
@@ -1404,16 +1393,11 @@ static int32_t smaIndexOptCreateSmaCols(SWindowLogicNode* pWindow, uint64_t tabl
int32_t
index
=
0
;
int32_t
smaFuncIndex
=
-
1
;
bool
hasWStart
=
false
;
SProjectLogicNode
*
pProject
=
(
SProjectLogicNode
*
)
pWindow
->
node
.
pParent
;
FOREACH
(
pFunc
,
pWindow
->
pFuncs
)
{
FOREACH
(
pFunc
,
pFuncs
)
{
smaFuncIndex
=
smaIndexOptFindSmaFunc
(
pFunc
,
pSmaFuncs
);
if
(
smaFuncIndex
<
0
)
{
break
;
}
else
{
if
(
pProject
&&
!
smaIndexOptFuncInProject
(
pProject
->
pProjections
,
(
SFunctionNode
*
)
pFunc
))
{
continue
;
}
code
=
nodesListMakeStrictAppend
(
&
pCols
,
smaIndexOptCreateSmaCol
(
pFunc
,
tableId
,
smaFuncIndex
+
1
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
...
...
@@ -1460,11 +1444,10 @@ static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo
if
(
!
smaIndexOptEqualInterval
(
pScan
,
pWindow
,
pIndex
))
{
return
TSDB_CODE_SUCCESS
;
}
SNodeList
*
pSmaFuncs
=
NULL
;
int32_t
code
=
nodesStringToList
(
pIndex
->
expr
,
&
pSmaFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
smaIndexOptCreateSmaCols
(
pWindow
,
pIndex
->
dstTbUid
,
pSmaFuncs
,
pCols
);
code
=
smaIndexOptCreateSmaCols
(
pWindow
->
pFuncs
,
pIndex
->
dstTbUid
,
pSmaFuncs
,
pCols
);
}
nodesDestroyList
(
pSmaFuncs
);
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录