提交 0408e5fa 编写于 作者: A Alex Duan

[TS-207]<fix>(query): sortGroupResByOrder function fixed groupby colid

上级 76742eef
...@@ -289,43 +289,35 @@ static int compareRowData(const void *a, const void *b, const void *userData) { ...@@ -289,43 +289,35 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
} }
static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock, SQLFunctionCtx *pCtx) { static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock, SQLFunctionCtx *pCtx) {
SArray *columnOrderList = getOrderCheckColumns(pRuntimeEnv->pQueryAttr); // get groupby first column index
size_t size = taosArrayGetSize(columnOrderList); SColIndex* pColIndex = taosArrayGet(pRuntimeEnv->pQueryAttr->pGroupbyExpr->columnInfo, 0);
taosArrayDestroy(&columnOrderList); if (pColIndex == NULL) {
if (size <= 0) {
return;
}
int32_t orderId = pRuntimeEnv->pQueryAttr->order.orderColId;
if (orderId <= 0) {
return; return;
} }
// search group by col index
int32_t orderIndex = -1; int32_t orderIndex = -1;
for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) { for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) {
if (pCtx[j].colId == orderId) { if (pCtx[j].colId == pColIndex->colId) {
orderIndex = j; orderIndex = j;
break; break;
} }
} }
if (orderIndex < 0) { if (orderIndex == -1) {
return; return;
} }
// get dataOffset
bool found = false; bool found = false;
int16_t dataOffset = 0; int16_t dataOffset = 0;
for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) { for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) {
SColumnInfoData* pColInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock->pDataBlock, j); SColumnInfoData* pColInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock->pDataBlock, j);
if (orderIndex == j) { if (orderIndex == j) {
found = true; found = true;
break; break;
} }
dataOffset += pColInfoData->info.bytes; dataOffset += pColInfoData->info.bytes;
} }
if (found == false) { if (found == false) {
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册