chore: only filter window pseudo column

This commit is contained in:
kailixu 2023-06-08 14:16:05 +08:00
parent 576e3d1156
commit 90b4580ba9
1 changed files with 22 additions and 15 deletions

View File

@ -749,22 +749,29 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
code = rewriteExprsForSelect(pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW, NULL); code = rewriteExprsForSelect(pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW, NULL);
} }
// erase duplicated funcNode by filtering colNode in pSelect->pProjectionList // erase duplicated Window Pseudo funcNode by filtering colNode in pSelect->pProjectionList
int32_t funcIndex = 0; if (pSelect->pProjectionList) {
SNode * pFunc = NULL, *pProject = NULL; int32_t funcIndex = 0;
FOREACH(pFunc, pWindow->pFuncs) { SNode * pFunc = NULL, *pProject = NULL;
bool exist = false; FOREACH(pFunc, pWindow->pFuncs) {
FOREACH(pProject, pSelect->pProjectionList) { if (!fmIsWindowPseudoColumnFunc(((SFunctionNode*)pFunc)->funcId)) {
if (0 != ((SFunctionNode*)pFunc)->node.aliasName[0] && ++funcIndex;
0 == strncmp(((SFunctionNode*)pFunc)->node.aliasName, ((SColumnNode*)pProject)->colName, TSDB_COL_NAME_LEN)) { continue;
exist = true; }
break; 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 (!exist) {
nodesListErase(pWindow->pFuncs, nodesListGetCell(pWindow->pFuncs, funcIndex));
} else {
++funcIndex;
} }
} }