Merge branch 'feat/TS-4243-3.0' of https://github.com/taosdata/TDengine into feat/TS-4243-3.0
This commit is contained in:
commit
81f0ff341c
|
@ -3968,22 +3968,33 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SArray* generateSortByTsInfo(SArray* colMatchInfo, int32_t order) {
|
SArray* generateSortByTsPkInfo(SArray* colMatchInfo, int32_t order) {
|
||||||
int32_t tsTargetSlotId = 0;
|
int32_t tsTargetSlotId = 0;
|
||||||
|
int32_t pkTargetSlotId = -1;
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) {
|
||||||
SColMatchItem* colInfo = taosArrayGet(colMatchInfo, i);
|
SColMatchItem* colInfo = taosArrayGet(colMatchInfo, i);
|
||||||
if (colInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (colInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
tsTargetSlotId = colInfo->dstSlotId;
|
tsTargetSlotId = colInfo->dstSlotId;
|
||||||
}
|
}
|
||||||
|
if (colInfo->isPk) {
|
||||||
|
pkTargetSlotId = colInfo->dstSlotId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||||
SBlockOrderInfo bi = {0};
|
SBlockOrderInfo biTs = {0};
|
||||||
bi.order = order;
|
biTs.order = order;
|
||||||
bi.slotId = tsTargetSlotId;
|
biTs.slotId = tsTargetSlotId;
|
||||||
bi.nullFirst = NULL_ORDER_FIRST;
|
biTs.nullFirst = NULL_ORDER_FIRST;
|
||||||
|
taosArrayPush(pList, &biTs);
|
||||||
|
|
||||||
taosArrayPush(pList, &bi);
|
if (pkTargetSlotId != -1) {
|
||||||
|
SBlockOrderInfo biPk = {0};
|
||||||
|
biPk.order = order;
|
||||||
|
biPk.slotId = pkTargetSlotId;
|
||||||
|
biPk.nullFirst = NULL_ORDER_FIRST;
|
||||||
|
taosArrayPush(pList, &biPk);
|
||||||
|
}
|
||||||
|
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
@ -4354,7 +4365,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
pInfo->bSortRowId = false;
|
pInfo->bSortRowId = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pSortInfo = generateSortByTsInfo(pInfo->base.matchInfo.pList, pInfo->base.cond.order);
|
pInfo->pSortInfo = generateSortByTsPkInfo(pInfo->base.matchInfo.pList, pInfo->base.cond.order);
|
||||||
pInfo->pReaderBlock = createOneDataBlock(pInfo->pResBlock, false);
|
pInfo->pReaderBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||||
|
|
||||||
pInfo->needCountEmptyTable = tsCountAlwaysReturnValue && pTableScanNode->needCountEmptyTable;
|
pInfo->needCountEmptyTable = tsCountAlwaysReturnValue && pTableScanNode->needCountEmptyTable;
|
||||||
|
|
|
@ -307,6 +307,26 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, const SSchema* pSchema, SNodeL
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t addPkCol(uint64_t tableId, const SSchema* pSchema, SNodeList** pCols) {
|
||||||
|
bool found = false;
|
||||||
|
SNode* pCol = NULL;
|
||||||
|
FOREACH(pCol, *pCols) {
|
||||||
|
if (pSchema->colId == ((SColumnNode*)pCol)->colId) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
return nodesListMakeStrictAppend(pCols, createFirstCol(tableId, pSchema));
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool hasPkInTable(const STableMeta* pTableMeta) {
|
||||||
|
return pTableMeta->tableInfo.numOfColumns>=2 && pTableMeta->schema[1].flags & COL_IS_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t addSystableFirstCol(uint64_t tableId, const SSchema* pSchema, SNodeList** pCols) {
|
static int32_t addSystableFirstCol(uint64_t tableId, const SSchema* pSchema, SNodeList** pCols) {
|
||||||
if (LIST_LENGTH(*pCols) > 0) {
|
if (LIST_LENGTH(*pCols) > 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -318,6 +338,9 @@ static int32_t addDefaultScanCol(const STableMeta* pMeta, SNodeList** pCols) {
|
||||||
if (TSDB_SYSTEM_TABLE == pMeta->tableType) {
|
if (TSDB_SYSTEM_TABLE == pMeta->tableType) {
|
||||||
return addSystableFirstCol(pMeta->uid, pMeta->schema, pCols);
|
return addSystableFirstCol(pMeta->uid, pMeta->schema, pCols);
|
||||||
}
|
}
|
||||||
|
if (hasPkInTable(pMeta)) {
|
||||||
|
addPkCol(pMeta->uid, pMeta->schema + 1, pCols);
|
||||||
|
}
|
||||||
return addPrimaryKeyCol(pMeta->uid, pMeta->schema, pCols);
|
return addPrimaryKeyCol(pMeta->uid, pMeta->schema, pCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue