diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index f273f6377074906b0db58aab00e4bd553ec294fe..2552523e73772de74bda01399796a995600b2da5 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -117,7 +117,7 @@ void* tableListDestroy(STableListInfo* pTableListInfo); void tableListClear(STableListInfo* pTableListInfo); int32_t tableListGetOutputGroups(const STableListInfo* pTableList); bool oneTableForEachGroup(const STableListInfo* pTableList); -uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid); +uint64_t tableListGetTableGroupId(const STableListInfo* pTableList, uint64_t tableUid); int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t gid); int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalIndex, STableKeyInfo** pKeyInfo, int32_t* num); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index ce39ebab5937c6576994458e05963fe0f373bf6a..a07a9d5dbd461fc326d6ab009c7784dc17faaea0 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -218,7 +218,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { return NULL; } - pRes->info.id.groupId = getTableGroupId(pTableList, pRes->info.id.uid); + pRes->info.id.groupId = tableListGetTableGroupId(pTableList, pRes->info.id.uid); pInfo->indexOfBufferedRes += 1; return pRes; } else { diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 5bb8f8a38becd05530f474f2b474c2f60d0bc3a2..057847e57aeb85ab374d5ec3c1d525e3609988f4 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1930,7 +1930,7 @@ void tableListGetSourceTableInfo(const STableListInfo* pTableList, uint64_t* psu *type = pTableList->idInfo.tableType; } -uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) { +uint64_t tableListGetTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) { int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid)); ASSERT(pTableList->map != NULL && slot != NULL); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 09b45d1c9d1e609f88901d3c24a060b8e4b44607..184cb558feba16bfd239056c5de76640b27df2d2 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -693,7 +693,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { } if (pBlock->info.id.uid) { - pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); + pBlock->info.id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); } uint32_t status = 0; @@ -1088,7 +1088,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU if (hasNext) { /*SSDataBlock* p = */ pAPI->tsdReader.tsdReaderRetrieveDataBlock(pReader, NULL); doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows); - pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); + pBlock->info.id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); } pAPI->tsdReader.tsdReaderClose(pReader); @@ -1110,7 +1110,7 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) { STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; - return getTableGroupId(pTableScanInfo->base.pTableListInfo, uid); + return tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, uid); } static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { @@ -1651,7 +1651,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock pBlockInfo->version = pBlock->info.version; STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; - pBlockInfo->id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); + pBlockInfo->id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); // todo extract method for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { @@ -2795,11 +2795,6 @@ static void tagScanFilterByTagCond(SArray* aUidTags, SNode* pTagCond, SArray* aF static void tagScanFillOneCellWithTag(const STUidTagInfo* pUidTagInfo, SExprInfo* pExprInfo, SColumnInfoData* pColInfo, int rowIndex, const SStorageAPI* pAPI, void* pVnode) { if (fmIsScanPseudoColumnFunc(pExprInfo->pExpr->_function.functionId)) { // tbname char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; -// if (pUidTagInfo->name != NULL) { -// STR_TO_VARSTR(str, pUidTagInfo->name); -// } else { // name is not retrieved during filter -// pAPI->metaFn.getTableNameByUid(pVnode, pUidTagInfo->uid, str); -// } STR_TO_VARSTR(str, "ctbidx"); colDataSetVal(pColInfo, rowIndex, str, false); @@ -3106,7 +3101,7 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { continue; } - pBlock->info.id.groupId = getTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); + pBlock->info.id.groupId = tableListGetTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); pOperator->resultInfo.totalRows += pBlock->info.rows; pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 7c97ec81a0eca34dc058fa7a43bfdc29b4987d20..3c02675bc71f68d828d1a2770b1d0ee792aa4e19 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -253,7 +253,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols return SCAN_TYPE_SYSTEM_TABLE; } - if (tagScan) { + if (tagScan && 0 == LIST_LENGTH(pScanCols) && 0 != LIST_LENGTH(pScanPseudoCols)) { return SCAN_TYPE_TAG; } @@ -366,17 +366,16 @@ static bool tagScanNodeHasTbname(SNode* pKeys) { return hasTbname; } -static int32_t setTagScanExecutionMode(SScanLogicNode* pScan) { - //TODO: set pScan->onlyMetaCtbIdx - bool bOnlyMetaCtbIdx = false; +static int32_t tagScanSetExecutionMode(SScanLogicNode* pScan) { + pScan->onlyMetaCtbIdx = false; if (tagScanNodeListHasTbname(pScan->pScanPseudoCols)) { - bOnlyMetaCtbIdx = false; + pScan->onlyMetaCtbIdx = false; return TSDB_CODE_SUCCESS; } if (pScan->node.pConditions == NULL) { - bOnlyMetaCtbIdx = true; + pScan->onlyMetaCtbIdx = true; return TSDB_CODE_SUCCESS; } @@ -385,9 +384,9 @@ static int32_t setTagScanExecutionMode(SScanLogicNode* pScan) { SNode* pTagIndexCond = NULL; filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL); if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) { - bOnlyMetaCtbIdx = false; + pScan->onlyMetaCtbIdx = false; } else { - bOnlyMetaCtbIdx = true; + pScan->onlyMetaCtbIdx = true; } nodesDestroyNode(pCond); nodesDestroyNode(pTagIndexCond); @@ -462,8 +461,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pScan->node.pTargets); } - if (pSelect->tagScan) { - code = setTagScanExecutionMode(pScan); + if (pScan->scanType == SCAN_TYPE_TAG) { + code = tagScanSetExecutionMode(pScan); } if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 6944fc9f1807c70246a802847dd54429e89edb7c..ff95f9a9883794e637416a34a2b9bb3b23500613 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1563,7 +1563,8 @@ static bool planOptNodeListHasTbname(SNodeList* pKeys) { static bool partTagsIsOptimizableNode(SLogicNode* pNode) { bool ret = 1 == LIST_LENGTH(pNode->pChildren) && - QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0)); + QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0) && + SCAN_TYPE_TAG != ((SScanLogicNode*)(nodesListGetNode(pNode->pChildren, 0)))->scanType); if (!ret) return ret; switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_PARTITION: {