diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index bde9b11601b3053ec58aacc3828ec5be1653a803..bccb52a592dcf56b4a73c58b9046407fdc15b921 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -92,6 +92,7 @@ typedef struct SResultRow { char *key; // start key of current result row SHashObj *uniqueHash; // for unique function SHashObj *modeHash; // for unique function + int32_t groupIndex; // index in group result } SResultRow; typedef struct SResultRowCell { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index f13d8e2154e793156ea7236d9a7d7a9418b70b89..a7e9d4a01483543a0671970b7cf20a5ca3ae9258 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -289,8 +289,8 @@ static int compareRowData(const void* a, const void* b, const void* userData) { char* in2 = NULL; SRowCompSupporter* supporter = (SRowCompSupporter*)userData; if (supporter->colData != NULL) { - in1 = supporter->colData + supporter->colBytes * TARRAY_ELEM_IDX(supporter->resultRows, pRow1); - in2 = supporter->colData + supporter->colBytes * TARRAY_ELEM_IDX(supporter->resultRows, pRow2); + in1 = supporter->colData + supporter->colBytes * pRow1->groupIndex; + in2 = supporter->colData + supporter->colBytes * pRow2->groupIndex; } else { SQueryRuntimeEnv* pRuntimeEnv = supporter->pRuntimeEnv; @@ -318,6 +318,7 @@ static int32_t getColDataFromGroupRes(SGroupResInfo* pGroupResInfo, SQueryRuntim int32_t numOfResult = 0; for (int32_t i = 0; i < numRows; ++i) { SResultRow* row = taosArrayGetP(pGroupResInfo->pRows, i); + row->groupIndex = i; tFilePage* page = getResBufPage(pRuntimeEnv->pResultBuf, row->pageId); int32_t rowsToCopy = 1; char* out = colData + numOfResult * colBytes;