From 4f258263951ace211ee79791f88080ee43096cc0 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 17 Dec 2021 06:44:27 +0800 Subject: [PATCH] the hidden column, result column id 0, would be the ts column of the outer query and inner query may not be sorted such as that diff then group by --- src/query/src/qPlan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/query/src/qPlan.c b/src/query/src/qPlan.c index 4c61cbb0f7..bd8a77b352 100644 --- a/src/query/src/qPlan.c +++ b/src/query/src/qPlan.c @@ -588,6 +588,12 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) { op = OP_Fill; taosArrayPush(plan, &op); } + // outer query order by support + int32_t orderColId = pQueryAttr->order.orderColId; + if (pQueryAttr->vgId == 0 && orderColId != INT32_MIN) { + op = OP_Order; + taosArrayPush(plan, &op); + } } } else if (pQueryAttr->groupbyColumn) { @@ -658,7 +664,7 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) { // outer query order by support int32_t orderColId = pQueryAttr->order.orderColId; - if (pQueryAttr->vgId == 0 && orderColId != PRIMARYKEY_TIMESTAMP_COL_INDEX && orderColId != INT32_MIN) { + if (pQueryAttr->vgId == 0 && orderColId != INT32_MIN) { op = OP_Order; taosArrayPush(plan, &op); } -- GitLab