From 91d3848c71da993ff8177d343f4f58ffb588cc1e Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 23 Mar 2024 20:24:50 +0800 Subject: [PATCH] fix: case issue --- include/libs/nodes/querynodes.h | 1 + source/common/src/tdatablock.c | 33 +++++++++++++++- source/libs/catalog/src/ctgAsync.c | 4 +- source/libs/command/src/command.c | 1 + source/libs/executor/src/mergejoin.c | 1 + source/libs/executor/test/joinTests.cpp | 2 +- source/libs/nodes/src/nodesCloneFuncs.c | 1 + source/libs/parser/src/parTranslater.c | 46 +++++++++++++++------- source/libs/parser/src/parUtil.c | 1 + source/libs/planner/src/planLogicCreater.c | 13 ++++-- source/libs/planner/src/planSpliter.c | 19 +++++---- tests/system-test/2-query/function_diff.py | 2 +- tests/system-test/2-query/mavg.py | 2 +- tests/system-test/2-query/nestedQuery.py | 21 +++++++--- tests/system-test/2-query/stablity.py | 38 +++++++++--------- tests/system-test/2-query/tail.py | 12 ++---- 16 files changed, 132 insertions(+), 65 deletions(-) diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index d19e1b9ddd..bed3aa4d2a 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -397,6 +397,7 @@ typedef struct SSelectStmt { uint8_t precision; int32_t selectFuncNum; int32_t returnRows; // EFuncReturnRows + ETimeLineMode timeLineCurMode; ETimeLineMode timeLineResMode; bool isEmptyResult; bool isSubquery; diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 45e089592e..2cf8518940 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -497,6 +497,7 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI if (IS_VAR_DATA_TYPE(pDst->info.type)) { int32_t allLen = 0; + void* srcAddr = NULL; if (pSrc->hasNull) { for (int32_t i = 0; i < numOfRows; ++i) { if (colDataIsNull_var(pSrc, srcIdx + i)) { @@ -506,6 +507,9 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI } char* pData = colDataGetVarData(pSrc, srcIdx + i); + if (NULL == srcAddr) { + srcAddr = pData; + } int32_t dataLen = 0; if (pSrc->info.type == TSDB_DATA_TYPE_JSON) { dataLen = getJsonValueLen(pData); @@ -540,8 +544,11 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI pDst->pData = tmp; pDst->varmeta.allocLen = pDst->varmeta.length + allLen; } - - memcpy(pDst->pData + pDst->varmeta.length, colDataGetVarData(pSrc, srcIdx), allLen); + if (pSrc->hasNull) { + memcpy(pDst->pData + pDst->varmeta.length, srcAddr, allLen); + } else { + memcpy(pDst->pData + pDst->varmeta.length, colDataGetVarData(pSrc, srcIdx), allLen); + } pDst->varmeta.length = pDst->varmeta.length + allLen; } } else { @@ -787,12 +794,34 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3 blockDataEnsureCapacity(pDst, rowCount); +/* may have disorder varchar data, TODO for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i); colDataAssignNRows(pDstCol, 0, pColData, startIndex, rowCount); } +*/ + + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); + SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i); + for (int32_t j = startIndex; j < (startIndex + rowCount); ++j) { + bool isNull = false; + if (pBlock->pBlockAgg == NULL) { + isNull = colDataIsNull_s(pColData, j); + } else { + isNull = colDataIsNull(pColData, pBlock->info.rows, j, pBlock->pBlockAgg[i]); + } + + if (isNull) { + colDataSetNULL(pDstCol, j - startIndex); + } else { + char* p = colDataGetData(pColData, j); + colDataSetVal(pDstCol, j - startIndex, p, false); + } + } + } pDst->info.rows = rowCount; return pDst; diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 65c2149261..39d3aa0ff7 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -2526,7 +2526,8 @@ int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) { SCtgViewsCtx* pCtx = (SCtgViewsCtx*)pTask->taskCtx; SCtgJob* pJob = pTask->pJob; bool tbMetaDone = false; - + +/* ctgIsTaskDone(pJob, CTG_TASK_GET_TB_META_BATCH, &tbMetaDone); if (tbMetaDone) { CTG_ERR_RET(ctgBuildViewNullRes(pTask, pCtx)); @@ -2535,6 +2536,7 @@ int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) { CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); return TSDB_CODE_SUCCESS; } +*/ int32_t dbNum = taosArrayGetSize(pCtx->pNames); int32_t fetchIdx = 0; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index c45a8931d2..be204bef16 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -747,6 +747,7 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate } SViewMeta* pMeta = pStmt->pViewMeta; + ASSERT(pMeta); snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s", pStmt->dbName, pStmt->viewName, pMeta->querySql); int32_t len = strlen(varDataVal(buf2)); varDataLen(buf2) = (len > 65535) ? 65535 : len; diff --git a/source/libs/executor/src/mergejoin.c b/source/libs/executor/src/mergejoin.c index 099d1fadee..ee8d3b5323 100755 --- a/source/libs/executor/src/mergejoin.c +++ b/source/libs/executor/src/mergejoin.c @@ -3386,6 +3386,7 @@ int32_t mJoinInitMergeCtx(SMJoinOperatorInfo* pJoin, SSortMergeJoinPhysiNode* pJ } pCtx->finBlk = createDataBlockFromDescNode(pJoinNode->node.pOutputDataBlockDesc); + ASSERT(pJoinNode->node.pOutputDataBlockDesc->totalRowSize > 0); blockDataEnsureCapacity(pCtx->finBlk, TMAX(MJOIN_DEFAULT_BLK_ROWS_NUM, MJOIN_BLK_SIZE_LIMIT/pJoinNode->node.pOutputDataBlockDesc->totalRowSize)); if (pJoin->pFPreFilter) { diff --git a/source/libs/executor/test/joinTests.cpp b/source/libs/executor/test/joinTests.cpp index cb921aece7..30d53136a7 100755 --- a/source/libs/executor/test/joinTests.cpp +++ b/source/libs/executor/test/joinTests.cpp @@ -3229,7 +3229,7 @@ TEST(fullOuterJoin, fullCondTest) { #endif #if 1 -#if 1 +#if 0 TEST(leftSemiJoin, noCondTest) { SJoinTestParam param; char* caseName = "leftSemiJoin:noCondTest"; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index c7f5628c9c..1a6fbfef87 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -815,6 +815,7 @@ static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(isEmptyResult); COPY_SCALAR_FIELD(timeLineResMode); + COPY_SCALAR_FIELD(timeLineCurMode); COPY_SCALAR_FIELD(hasAggFuncs); COPY_SCALAR_FIELD(hasRepeatScanFuncs); CLONE_NODE_LIST_FIELD(pHint); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 4be3664fd3..76e3c058dc 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -889,9 +889,9 @@ static SNodeList* getProjectList(const SNode* pNode) { static bool isBlockTimeLineQuery(SNode* pStmt) { if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineResMode) || - (TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineResMode) || - (TIME_LINE_BLOCK == ((SSelectStmt*)pStmt)->timeLineResMode); + return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineCurMode) || + (TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineCurMode) || + (TIME_LINE_BLOCK == ((SSelectStmt*)pStmt)->timeLineCurMode); } else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) { return TIME_LINE_GLOBAL == ((SSetOperator*)pStmt)->timeLineResMode; } else { @@ -901,8 +901,8 @@ static bool isBlockTimeLineQuery(SNode* pStmt) { static bool isTimeLineQuery(SNode* pStmt) { if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineResMode) || - (TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineResMode); + return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineCurMode) || + (TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineCurMode); } else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) { return TIME_LINE_GLOBAL == ((SSetOperator*)pStmt)->timeLineResMode; } else { @@ -920,6 +920,17 @@ static bool isGlobalTimeLineQuery(SNode* pStmt) { } } +static bool isCurGlobalTimeLineQuery(SNode* pStmt) { + if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + return TIME_LINE_GLOBAL == ((SSelectStmt*)pStmt)->timeLineCurMode; + } else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) { + return TIME_LINE_GLOBAL == ((SSetOperator*)pStmt)->timeLineResMode; + } else { + return false; + } +} + + static bool isBlockTimeLineAlignedQuery(SNode* pStmt) { SSelectStmt* pSelect = (SSelectStmt*)pStmt; if (!isBlockTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { @@ -2129,7 +2140,7 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && - (TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode))) { + (TIME_LINE_GLOBAL != pSelect->timeLineCurMode && TIME_LINE_MULTI != pSelect->timeLineCurMode))) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s function requires valid time series input", pFunc->functionName); } @@ -3869,16 +3880,16 @@ static int32_t setJoinTimeLineResMode(STranslateContext* pCxt) { SJoinTableNode* pJoinTable = (SJoinTableNode*)pCurrSmt->pFromTable; if (JOIN_TYPE_FULL == pJoinTable->joinType) { pCurrSmt->timeLineResMode = TIME_LINE_NONE; - return TSDB_CODE_SUCCESS; - } - - if (TIME_LINE_NONE == pCurrSmt->timeLineResMode) { + pCurrSmt->timeLineCurMode = TIME_LINE_NONE; return TSDB_CODE_SUCCESS; } if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { if (joinNonPrimColCondContains(pJoinTable)) { - pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; + if (TIME_LINE_NONE != pCurrSmt->timeLineResMode) { + pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; + } + pCurrSmt->timeLineCurMode = TIME_LINE_BLOCK; } return TSDB_CODE_SUCCESS; } @@ -3888,7 +3899,10 @@ static int32_t setJoinTimeLineResMode(STranslateContext* pCxt) { } if (JOIN_STYPE_NONE == pJoinTable->subType && innerJoinTagEqCondContains(pJoinTable, pCurrSmt->pWhere)) { - pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; + if (TIME_LINE_NONE != pCurrSmt->timeLineResMode) { + pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; + } + pCurrSmt->timeLineCurMode = TIME_LINE_BLOCK; } return TSDB_CODE_SUCCESS; @@ -3930,6 +3944,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) { if (isSelectStmt(pCxt->pCurrStmt)) { ((SSelectStmt*)pCxt->pCurrStmt)->timeLineResMode = TIME_LINE_NONE; + ((SSelectStmt*)pCxt->pCurrStmt)->timeLineCurMode = TIME_LINE_NONE; } else if (isDeleteStmt(pCxt->pCurrStmt)) { code = TSDB_CODE_TSC_INVALID_OPERATION; break; @@ -3951,6 +3966,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare pCurrSmt->joinContains = ((SSelectStmt*)pTempTable->pSubquery)->joinContains; SSelectStmt* pSubStmt = (SSelectStmt*)pTempTable->pSubquery; pCurrSmt->timeLineResMode = pSubStmt->timeLineResMode; + pCurrSmt->timeLineCurMode = pSubStmt->timeLineResMode; } pCurrSmt->joinContains = (getJoinContais(pTempTable->pSubquery) ? true : false); @@ -4833,7 +4849,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && - (TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode)))) { + (TIME_LINE_GLOBAL != pSelect->timeLineCurMode && TIME_LINE_MULTI != pSelect->timeLineCurMode)))) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); } @@ -4842,7 +4858,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { !isBlockTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && - (TIME_LINE_NONE == pSelect->timeLineResMode)))) { + (TIME_LINE_NONE == pSelect->timeLineCurMode)))) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); } @@ -5386,7 +5402,7 @@ static EDealRes appendTsForImplicitTsFuncImpl(SNode* pNode, void* pContext) { !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && - (TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode))) { + (TIME_LINE_GLOBAL != pSelect->timeLineCurMode && TIME_LINE_MULTI != pSelect->timeLineCurMode))) { pCxt->errCode = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s function requires valid time series input", pFunc->functionName); return DEAL_RES_ERROR; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index de09a78752..feb2ee1667 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -733,6 +733,7 @@ SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* select->pFromTable = pTable; sprintf(select->stmtName, "%p", select); select->timeLineResMode = select->isDistinct ? TIME_LINE_NONE : TIME_LINE_GLOBAL; + select->timeLineCurMode = TIME_LINE_GLOBAL; select->onlyHasKeepOrderFunc = true; select->timeRange = TSWINDOW_INITIALIZER; select->pHint = pHint; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index f08fcab6f8..cdcb3578b3 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -644,6 +644,14 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } nodesDestroyList(pColList); } + + if (NULL == pJoin->node.pTargets && NULL != pLeft) { + pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); + if (NULL == pJoin->node.pTargets) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + #endif @@ -1384,11 +1392,10 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); } -/* if (TSDB_CODE_SUCCESS == code) { - code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs); +// code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs); + code = nodesCollectFuncs(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, fmIsAggFunc, &pPartition->pAggFuncs); } -*/ if (TSDB_CODE_SUCCESS == code) { pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index a6b97c7c04..a449071eb7 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1369,7 +1369,7 @@ static int32_t stbSplCreateMergeScanNode(SScanLogicNode* pScan, SLogicNode** pOu } static int32_t stbSplSplitMergeScanNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan, - bool groupSort) { + bool groupSort, SStableSplitInfo* pInfo) { SLogicNode* pMergeScan = NULL; SNodeList* pMergeKeys = NULL; int32_t code = stbSplCreateMergeScanNode(pScan, &pMergeScan, &pMergeKeys); @@ -1381,6 +1381,9 @@ static int32_t stbSplSplitMergeScanNode(SSplitContext* pCxt, SLogicSubplan* pSub code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, pMergeScan, groupSort, true); } if (TSDB_CODE_SUCCESS == code) { + if ((void*)pInfo->pSplitNode == (void*)pScan) { + pInfo->pSplitNode = NULL; + } nodesDestroyNode((SNode*)pScan); code = nodesListMakeStrictAppend(&pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, pMergeScan, SPLIT_FLAG_STABLE_SPLIT)); @@ -1393,7 +1396,7 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) SScanLogicNode* pScan = (SScanLogicNode*)pInfo->pSplitNode; if (SCAN_TYPE_TABLE_MERGE == pScan->scanType) { pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; - return stbSplSplitMergeScanNode(pCxt, pInfo->pSubplan, pScan, true); + return stbSplSplitMergeScanNode(pCxt, pInfo->pSubplan, pScan, true, pInfo); } if (NULL != pScan->pGroupTags) { return stbSplSplitScanNodeWithPartTags(pCxt, pInfo); @@ -1401,7 +1404,7 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) return stbSplSplitScanNodeWithoutPartTags(pCxt, pInfo); } -static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubplan, SJoinLogicNode* pJoin) { +static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubplan, SJoinLogicNode* pJoin, SStableSplitInfo* pInfo) { int32_t code = TSDB_CODE_SUCCESS; SNode* pChild = NULL; FOREACH(pChild, pJoin->node.pChildren) { @@ -1409,10 +1412,10 @@ static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubp //if (pJoin->node.dynamicOp) { // code = TSDB_CODE_SUCCESS; //} else { - code = stbSplSplitMergeScanNode(pCxt, pSubplan, (SScanLogicNode*)pChild, pJoin->grpJoin ? true : false); + code = stbSplSplitMergeScanNode(pCxt, pSubplan, (SScanLogicNode*)pChild, pJoin->grpJoin ? true : false, pInfo); //} } else if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pChild)) { - code = stbSplSplitJoinNodeImpl(pCxt, pSubplan, (SJoinLogicNode*)pChild); + code = stbSplSplitJoinNodeImpl(pCxt, pSubplan, (SJoinLogicNode*)pChild, pInfo); } else { code = TSDB_CODE_PLAN_INTERNAL_ERROR; } @@ -1424,7 +1427,7 @@ static int32_t stbSplSplitJoinNodeImpl(SSplitContext* pCxt, SLogicSubplan* pSubp } static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { - int32_t code = stbSplSplitJoinNodeImpl(pCxt, pInfo->pSubplan, (SJoinLogicNode*)pInfo->pSplitNode); + int32_t code = stbSplSplitJoinNodeImpl(pCxt, pInfo->pSubplan, (SJoinLogicNode*)pInfo->pSplitNode, pInfo); if (TSDB_CODE_SUCCESS == code) { //if (!pInfo->pSplitNode->dynamicOp) { pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; @@ -1500,7 +1503,9 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { break; } - info.pSplitNode->splitDone = true; + if (info.pSplitNode) { + info.pSplitNode->splitDone = true; + } pCxt->split = true; return code; } diff --git a/tests/system-test/2-query/function_diff.py b/tests/system-test/2-query/function_diff.py index 493e59265e..4025f2ad47 100644 --- a/tests/system-test/2-query/function_diff.py +++ b/tests/system-test/2-query/function_diff.py @@ -295,7 +295,7 @@ class TDTestCase: "table_expr": "db.stb1 as stable1, db.stb2 as stable2", "condition": "where stable1.ts=stable2.ts and stable1.st1=stable2.st2 order by stable1.ts" } - tdSql.query(self.diff_query_form(**stb_join)) # stb join + tdSql.error(self.diff_query_form(**stb_join)) # stb join interval_sql = { "condition": "where ts>0 and ts < now interval(1h) fill(next)" } diff --git a/tests/system-test/2-query/mavg.py b/tests/system-test/2-query/mavg.py index 798d0e290b..7556c9942d 100644 --- a/tests/system-test/2-query/mavg.py +++ b/tests/system-test/2-query/mavg.py @@ -498,7 +498,7 @@ class TDTestCase: # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" # } # self.checkmavg(**err44) # stb join - tdSql.query(f"select mavg( stb1.c1 , 1 ) from {dbname}.stb1 stb1, {dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;") + tdSql.error(f"select mavg( stb1.c1 , 1 ) from {dbname}.stb1 stb1, {dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;") err45 = { "condition": "where ts>0 and ts < now interval(1h) fill(next)" } diff --git a/tests/system-test/2-query/nestedQuery.py b/tests/system-test/2-query/nestedQuery.py index 5876d2f208..91fae85425 100755 --- a/tests/system-test/2-query/nestedQuery.py +++ b/tests/system-test/2-query/nestedQuery.py @@ -1377,8 +1377,19 @@ class TDTestCase: tdSql.query(sql) self.cur1.execute(sql) self.explain_sql(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + elif (mathlist == ['MAVG']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['UNIQUE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + elif (mathlist == ['SAMPLE']) or (mathlist == ['HISTOGRAM']) or (mathlist == ['HYPERLOGLOG']) (mathlist == ['MODE']) : sql = "select count(asct1) from ( select " sql += "%s as asct1 " % math_fun_join_2 sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " @@ -1391,7 +1402,7 @@ class TDTestCase: tdLog.info(len(sql)) tdSql.query(sql) self.cur1.execute(sql) - self.explain_sql(sql) + self.explain_sql(sql) self.restartDnodes() tdSql.query("select 1-10 as math_nest from stable_1 limit 1;") @@ -3337,9 +3348,7 @@ class TDTestCase: sql += ") ;" tdLog.info(sql) tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - self.explain_sql(sql) + tdSql.error(sql) self.restartDnodes() tdSql.query("select 1-10 as time_nest from stable_1 limit 1;") diff --git a/tests/system-test/2-query/stablity.py b/tests/system-test/2-query/stablity.py index 5e4d5dcbaf..23972374aa 100755 --- a/tests/system-test/2-query/stablity.py +++ b/tests/system-test/2-query/stablity.py @@ -1239,8 +1239,7 @@ class TDTestCase: tdLog.info(sql) tdSql.query(sql) self.explain_sql(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + elif (mathlist == ['SAMPLE']) or (mathlist == ['HISTOGRAM']) or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['MODE']) : sql = "select %s as asct1 " % math_fun_join_2 sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " sql += "%s " % random.choice(self.t_join_where) @@ -1250,6 +1249,15 @@ class TDTestCase: tdLog.info(sql) tdSql.query(sql) self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['UNIQUE']) or (mathlist == ['statecount','stateduration']) : + sql = "select %s as asct1 " % math_fun_join_2 + sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdSql.error(sql) tdSql.query("select 1-10 as math_nest from stable_1 limit 1;") for i in range(self.fornum): @@ -3025,8 +3033,7 @@ class TDTestCase: sql += "%s " % random.choice(self.limit1_where) sql += ") ;" tdLog.info(sql) - tdSql.query(sql) - self.explain_sql(sql) + tdSql.error(sql) tdSql.query("select 1-10 as time_nest from stable_1 limit 1;") @@ -3351,8 +3358,7 @@ class TDTestCase: sql += ") " sql += "%s ;" % random.choice(self.limit_u_where) tdLog.info(sql) - tdSql.query(sql) - self.explain_sql(sql) + tdSql.error(sql) #taos -f sql startTime_taos_f = time.time() @@ -3796,9 +3802,7 @@ class TDTestCase: for i in range(self.fornum): sql = "select * from ( select " sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts " sql += "%s " % random.choice(self.limit1_where) sql += ") ;" tdLog.info(sql) @@ -3924,8 +3928,7 @@ class TDTestCase: for i in range(self.fornum): sql = "select * from ( select " sql += "%s " % random.choice(self.calc_calculate_regular_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts " sql += "%s " % random.choice(self.partiton_where_j) sql += ") " sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) @@ -4044,9 +4047,7 @@ class TDTestCase: for i in range(self.fornum): sql = "select * from ( select " sql += "%s as calc15_2 " % random.choice(self.calc_aggregate_regular_j) - sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.group_where_regular_j) + sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts " sql += "%s " % random.choice(self.limit_u_where) sql += ") " sql += "%s ;" % random.choice(self.limit_u_where) @@ -4093,8 +4094,7 @@ class TDTestCase: sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j) sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j) sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) + sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts " sql += "%s " % random.choice(self.group_only_where_j) sql += "%s " % random.choice(self.having_support_j) sql += ") " @@ -4234,8 +4234,7 @@ class TDTestCase: for i in range(self.fornum): sql = "select * from ( select " sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts " sql += "limit 2 ) " sql += "%s " % random.choice(self.limit1_where) tdLog.info(sql) @@ -4547,8 +4546,7 @@ class TDTestCase: sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) + sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts " sql += "%s " % random.choice(self.session_u_where) sql += "%s " % random.choice(self.limit_u_where) sql += ") " diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index 99791db3df..d3cacbdaf1 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -412,17 +412,13 @@ class TDTestCase: tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) - tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 group by c2);") - tdSql.checkRows(1) + tdSql.error(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 group by c2);") - tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 partition by c2);") - tdSql.checkRows(1) + tdSql.error(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 partition by c2);") - tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 order by c2);") - tdSql.checkRows(1) + tdSql.error(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 order by c2);") - tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 union select _rowts, first(c2) as a from {dbname}.ct1);") - tdSql.checkRows(1) + tdSql.error(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 union select _rowts, first(c2) as a from {dbname}.ct1);") def check_boundary_values(self, dbname="bound_test"):