diff --git a/src/system/detail/inc/vnodeRead.h b/src/system/detail/inc/vnodeRead.h index 0b818ecd3a980ed8f8fec812475db466ef614757..0e5f40cd47819c0f400068dce9c7e98eb6a77dd8 100644 --- a/src/system/detail/inc/vnodeRead.h +++ b/src/system/detail/inc/vnodeRead.h @@ -146,7 +146,7 @@ typedef struct SQueryRuntimeEnv { SPositionInfo endPos; /* the last access position in query, served as the start pos of reversed order query */ SPositionInfo nextPos; /* start position of the next scan */ SData* colDataBuffer[TSDB_MAX_COLUMNS]; - SResultInfo* resultInfo; + SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo uint8_t blockStatus; // Indicate if data block is loaded, the block is first/last/internal block int32_t unzipBufSize; SData* primaryColBuffer; diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index aebd5b28c6a20e83be0dc2f967542c28cb71ff64..1421a295f3f76cbe090f708fc060a3ba8989d252 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -3945,9 +3945,9 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool metricQuery) { // in case of point-interpolation query, use asc order scan char msg[] = "QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64 "-%" PRId64 - ", " - "new qrange:%" PRId64 "-%" PRId64; + ", new qrange:%" PRId64 "-%" PRId64; + // todo handle the case the the order irrelevant query type mixed up with order critical query type // descending order query for last_row query if (isFirstLastRowQuery(pQuery)) { dTrace("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery), @@ -5881,7 +5881,21 @@ void disableFunctForTableSuppleScan(SQueryRuntimeEnv *pRuntimeEnv, int32_t order } SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo; - doDisableFunctsForSupplementaryScan(pQuery, pWindowResInfo, order); + if (isGroupbyNormalCol(pQuery->pGroupbyExpr) || isIntervalQuery(pQuery)) { + doDisableFunctsForSupplementaryScan(pQuery, pWindowResInfo, order); + } else { // for simple result of table query, + for (int32_t j = 0; j < pQuery->numOfOutputCols; ++j) { + int32_t functId = pQuery->pSelectExpr[j].pBase.functionId; + SQLFunctionCtx* pCtx = &pRuntimeEnv->pCtx[j]; + + if (((functId == TSDB_FUNC_FIRST || functId == TSDB_FUNC_FIRST_DST) && order == TSQL_SO_DESC) || + ((functId == TSDB_FUNC_LAST || functId == TSDB_FUNC_LAST_DST) && order == TSQL_SO_ASC)) { + pCtx->resultInfo->complete = false; + } else if (functId != TSDB_FUNC_TS && functId != TSDB_FUNC_TAG) { + pCtx->resultInfo->complete = true; + } + } + } pQuery->order.order = pQuery->order.order ^ 1u; }