From 8ad1489c666fc7085481a1bddf0aa7b81eb3726c Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Sat, 23 Jul 2022 15:06:12 +0800 Subject: [PATCH] fix: semantic check when last(*) and column are together --- source/libs/parser/src/parTranslater.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c99080c2a3..93fffee956 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1237,7 +1237,9 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { pSelect->hasMultiRowsFunc = pSelect->hasMultiRowsFunc ? true : fmIsMultiRowsFunc(pFunc->funcId); if (fmIsSelectFunc(pFunc->funcId)) { pSelect->hasSelectFunc = true; - pSelect->selectFuncNum += fmIsMultiResFunc(pFunc->funcId) ? getMultiResFuncNum(pFunc->pParameterList) : 1; + pSelect->selectFuncNum += (fmIsMultiResFunc(pFunc->funcId) && !fmIsLastRowFunc(pFunc->funcId)) + ? getMultiResFuncNum(pFunc->pParameterList) + : 1; } else if (fmIsVectorFunc(pFunc->funcId)) { pSelect->hasOtherVectorFunc = true; } @@ -2142,6 +2144,15 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } +static int32_t translateFillValues(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (NULL == pSelect->pWindow || QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) || + NULL == ((SIntervalWindowNode*)pSelect->pWindow)->pFill) { + return TSDB_CODE_SUCCESS; + } + SFillNode* pFill = (SFillNode*)((SIntervalWindowNode*)pSelect->pWindow)->pFill; + return TSDB_CODE_SUCCESS; +} + static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) { pCxt->currClause = SQL_CLAUSE_SELECT; int32_t code = translateExprList(pCxt, pSelect->pProjectionList); @@ -2151,6 +2162,9 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList); } + if (TSDB_CODE_SUCCESS == code) { + code = translateFillValues(pCxt, pSelect); + } return code; } -- GitLab