fix: last row scan and tag in conds issues

This commit is contained in:
dapan1121 2025-02-18 19:27:47 +08:00
parent cbfc52427e
commit df674440bf
3 changed files with 62 additions and 11 deletions

View File

@ -398,7 +398,6 @@ static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
// check for tag values
if (pInfo->pRes->info.rows > 0) {
if (pInfo->pseudoExprSup.numOfExprs > 0) {
SExprSupp* pSup = &pInfo->pseudoExprSup;
STableKeyInfo* pKeyInfo = &((STableKeyInfo*)pList)[0];
@ -408,6 +407,7 @@ static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
void* pUid = taosArrayGet(pInfo->pUidList, 0);
QUERY_CHECK_NULL(pUid, code, lino, _end, terrno);
pInfo->pRes->info.id.uid = *(tb_uid_t*)pUid;
if (pInfo->pseudoExprSup.numOfExprs > 0) {
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
pInfo->pRes->info.rows, pTaskInfo, NULL);
QUERY_CHECK_CODE(code, lino, _end);

View File

@ -93,6 +93,12 @@ typedef struct SCpdCollectTableColCxt {
int32_t errCode;
} SCpdCollectTableColCxt;
typedef struct SCollectColsCxt {
SHashObj* pColHash;
int32_t errCode;
} SCollectColsCxt;
typedef enum ECondAction {
COND_ACTION_STAY = 1,
COND_ACTION_PUSH_JOIN,
@ -3302,11 +3308,54 @@ static int32_t partTagsRewriteGroupTagsToFuncs(SNodeList* pGroupTags, int32_t st
return code;
}
static EDealRes partTagsCollectColsNodes(SNode* pNode, void* pContext) {
SCollectColsCxt* pCxt = pContext;
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
SColumnNode* pCol = (SColumnNode*)pNode;
if (NULL == taosHashGet(pCxt->pColHash, pCol->colName, strlen(pCol->colName))) {
pCxt->errCode = taosHashPut(pCxt->pColHash, pCol->colName, strlen(pCol->colName), NULL, 0);
}
}
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR);
}
static bool partTagsIsScanPseudoColsInConds(SScanLogicNode* pScan) {
SCollectColsCxt cxt = {
.errCode = TSDB_CODE_SUCCESS,
.pColHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)};
if (NULL == cxt.pColHash) {
return true;
}
nodesWalkExpr(pScan->node.pConditions, partTagsCollectColsNodes, &cxt);
if (cxt.errCode) {
taosHashCleanup(cxt.pColHash);
return true;
}
SNode* pNode = NULL;
FOREACH(pNode, pScan->pScanPseudoCols) {
if (taosHashGet(cxt.pColHash, ((SExprNode*)pNode)->aliasName, strlen(((SExprNode*)pNode)->aliasName))) {
taosHashCleanup(cxt.pColHash);
return true;
}
}
taosHashCleanup(cxt.pColHash);
return false;
}
static int32_t partTagsOptRemovePseudoCols(SScanLogicNode* pScan) {
if (!pScan->noPseudoRefAfterGrp || NULL == pScan->pScanPseudoCols || pScan->pScanPseudoCols->length <= 0) {
return TSDB_CODE_SUCCESS;
}
if (pScan->node.pConditions && partTagsIsScanPseudoColsInConds(pScan)) {
return TSDB_CODE_SUCCESS;
}
SNode* pNode = NULL, *pTarget = NULL;
FOREACH(pNode, pScan->pScanPseudoCols) {
FOREACH(pTarget, pScan->node.pTargets) {

View File

@ -22,8 +22,10 @@
#include "trpc.h"
int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) {
int32_t code = 0;
SCH_ERR_JRET(schUpdateJobStatus(pJob, status));
int32_t code = schUpdateJobStatus(pJob, status);
if (TSDB_CODE_SUCCESS != code) {
SCH_ERR_JRET((param && *(int32_t*)param) ? *(int32_t*)param : code);
}
switch (status) {
case JOB_TASK_STATUS_INIT: