From c5cfeee49373c48dee545161cbe6eaff2211efbc Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 20 Aug 2020 23:40:39 +0800 Subject: [PATCH] [td-1067] fix bugs in lastrow query. --- src/query/src/qExecutor.c | 2 +- src/tsdb/src/tsdbRead.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1103b9b531..bf72f209d6 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5262,7 +5262,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { int64_t st = taosGetTimestampUs(); if (QUERY_IS_INTERVAL_QUERY(pQuery) || - (isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && !pRuntimeEnv->groupbyNormalCol)) { + (isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyNormalCol))) { multiTableQueryProcess(pQInfo); } else { assert((pQuery->checkBuffer == 1 && pQuery->intervalTime == 0) || isPointInterpoQuery(pQuery) || diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index ba46427b1a..b189c7a406 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -301,6 +301,9 @@ TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STab pCond->order = TSDB_ORDER_DESC; pCond->twindow = changeTableGroupByLastrow(groupList); + //descending order query, skey >= ekey + SWAP(pCond->twindow.skey, pCond->twindow.ekey, TSKEY); + STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo); return pQueryHandle; } -- GitLab