scan cols sort

This commit is contained in:
Xiaoyu Wang 2022-03-25 01:41:28 -04:00
parent 1122d23bb2
commit 9765678e75
3 changed files with 29 additions and 4 deletions

View File

@ -5569,7 +5569,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo *pOperator, bool* newgroup) {
blockDataCleanup(pInfo->pRes);
int32_t tableNameSlotId = 1;
int32_t tableNameSlotId = 0;
SColumnInfoData* pTableNameCol = taosArrayGet(pInfo->pRes->pDataBlock, tableNameSlotId);
char * name = NULL;

View File

@ -358,7 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION));
}
TEST_F(ParserTest, showUsers) {
setDatabase("root", "test");
@ -366,8 +365,6 @@ TEST_F(ParserTest, showUsers) {
ASSERT_TRUE(run());
}
TEST_F(ParserTest, createDnode) {
setDatabase("root", "test");

View File

@ -213,6 +213,33 @@ static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
return pCol;
}
static int32_t colIdCompare(const void* pLeft, const void* pRight) {
SColumnNode* pLeftCol = *(SColumnNode**)pLeft;
SColumnNode* pRightCol = *(SColumnNode**)pRight;
return pLeftCol->colId > pRightCol->colId ? 1 : -1;
}
static int32_t sortScanCols(SNodeList* pScanCols) {
SArray* pArray = taosArrayInit(LIST_LENGTH(pScanCols), POINTER_BYTES);
if (NULL == pArray) {
return TSDB_CODE_OUT_OF_MEMORY;
}
SNode* pCol = NULL;
FOREACH(pCol, pScanCols) {
taosArrayPush(pArray, &pCol);
}
taosArraySort(pArray, colIdCompare);
int32_t index = 0;
FOREACH(pCol, pScanCols) {
REPLACE_NODE(taosArrayGetP(pArray, index++));
}
taosArrayDestroy(pArray);
return TSDB_CODE_SUCCESS;
}
static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhysiNode, SNodeList* pScanCols) {
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanPhysiNode)
|| QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN == nodeType(pScanPhysiNode)) {
@ -235,6 +262,7 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
CHECK_ALLOC(pScanPhysiNode->pScanCols, TSDB_CODE_OUT_OF_MEMORY);
}
// return sortScanCols(pScanPhysiNode->pScanCols);
return TSDB_CODE_SUCCESS;
}