diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 8a766ae7e8f78fe574e6a49c5b2eecd75b316c3f..656caaf645e150dae418e40e1f86adcf345e1e12 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -56,6 +56,20 @@ typedef enum ECondAction { // after supporting outer join, there are other possibilities } ECondAction; +EDealRes haveNormalColImpl(SNode* pNode, void* pContext) { + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); + return *((bool*)pContext) ? DEAL_RES_END : DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static bool haveNormalCol(SNodeList* pList) { + bool res = false; + nodesWalkExprsPostOrder(pList, haveNormalColImpl, &res); + return res; +} + static bool osdMayBeOptimized(SLogicNode* pNode) { if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_OSD)) { return false; @@ -67,7 +81,10 @@ static bool osdMayBeOptimized(SLogicNode* pNode) { (QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent))) { return false; } - return true; + if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent)) { + return (WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pNode->pParent)->winType); + } + return !haveNormalCol(((SAggLogicNode*)pNode->pParent)->pGroupKeys); } static SLogicNode* osdFindPossibleScanNode(SLogicNode* pNode) { diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 14fa36a95814896e9b7daffd6807f352bc3b8d62..1171c9d4ac1d9c74bcb17a4eea029b76469a8f46 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -45,7 +45,7 @@ protected: int32_t code = qParseQuerySql(&cxt_, &query_); if (code != TSDB_CODE_SUCCESS) { - cout << "sql:[" << cxt_.pSql << "] parser code:" << code << ", strerror:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; + cout << "sql:[" << cxt_.pSql << "] qParseQuerySql code:" << code << ", strerror:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; return false; }