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