diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 0fc7f0e697361f1c7e3811c3f398632a921b7a5f..05831b8dfffc2dc14a5ec2a893c53cc99edf78ca 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6169,6 +6169,7 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI goto _clean; } + bool found = false; for (int32_t i = 0; i < numOfOutput; ++i) { SColumnInfoData col = {{0}}; col.info.colId = pExpr[i].base.colInfo.colId; @@ -6176,8 +6177,9 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI col.info.type = pExpr[i].base.resType; taosArrayPush(pDataBlock->pDataBlock, &col); - if (col.info.colId == pOrderVal->orderColId) { + if (!found && col.info.colId == pOrderVal->orderColId) { pInfo->colIndex = i; + found = true; } }