From 38ae79e6e0a7f823908ef9f4cce5d8f0ee9e8d6d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 28 Jun 2022 14:32:58 +0800 Subject: [PATCH] feat: refactor the plan implementation of unique function --- source/libs/planner/src/planOptimizer.c | 3 ++- source/libs/planner/test/planBasicTest.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 1927afec0f..42f7f744c5 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1623,7 +1623,7 @@ static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { } SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pChild) || 1 < LIST_LENGTH(pChild->pChildren) || - NULL != pChild->pConditions || NULL != pNode->pLimit || NULL != pNode->pSlimit) { + NULL != pChild->pConditions || NULL != pChild->pLimit || NULL != pChild->pSlimit) { return false; } return true; @@ -1680,6 +1680,7 @@ static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* NODES_CLEAR_LIST(pChild->pChildren); } nodesDestroyNode((SNode*)pChild); + pCxt->optimized = true; return code; } diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index dbedb2d787..ff725c444e 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -77,6 +77,8 @@ TEST_F(PlanBasicTest, tailFunc) { run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 LIMIT 5"); run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5"); + + run("SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2"); } TEST_F(PlanBasicTest, interpFunc) {