diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 2db0c8c54b21fd3fd512b4060b46beea534909c2..7ce6994ce6b7e0d5dfd30a760525b0b85fe6bd29 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -3192,7 +3192,7 @@ static bool stbJoinOptShouldBeOptimized(SLogicNode* pNode) { } SJoinLogicNode* pJoin = (SJoinLogicNode*)pNode; - if (pJoin->isSingleTableJoin || NULL == pJoin->pTagEqCond || pNode->pChildren->length != 2 + if (pJoin->isSingleTableJoin || NULL == pJoin->pTagEqCond || NULL != pJoin->pTagOnCond || pNode->pChildren->length != 2 || pJoin->hasSubQuery || pJoin->joinAlgo != JOIN_ALGO_UNKNOWN || pJoin->isLowLevelJoin) { if (pJoin->joinAlgo == JOIN_ALGO_UNKNOWN) { pJoin->joinAlgo = JOIN_ALGO_MERGE; diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index 2ce920a9d28bc96d64b8d9e4a3967dfc069acdf3..3b127ee780e4bae1eaca7db698eff8782f32af3e 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -314,7 +314,6 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) { } taosArrayDestroy(ctx->tbInfo); - ctx->tbInfo = NULL; } int32_t qwDropTaskCtx(QW_FPARAMS_DEF) { @@ -341,6 +340,7 @@ int32_t qwDropTaskCtx(QW_FPARAMS_DEF) { } qwFreeTaskCtx(&octx); + ctx->tbInfo = NULL; QW_TASK_DLOG_E("task ctx dropped"); diff --git a/tests/system-test/2-query/stbJoin.py b/tests/system-test/2-query/stbJoin.py index ce6da6eb1c28fd6538c6a2587fa360c0707726d6..3913a8159f43badf54b4d45a90275f5f5d630287 100644 --- a/tests/system-test/2-query/stbJoin.py +++ b/tests/system-test/2-query/stbJoin.py @@ -103,6 +103,8 @@ class TDTestCase: tdSql.query(f"select /*+ no_batch_scan() */ count(*) from sta a, stb b where a.tg1=b.tg1 and a.ts=b.ts and b.tg2 > 'a' interval(1a);") tdSql.checkRows(3) + tdSql.query(f"select a.ts, b.ts from sta a, stb b where a.ts=b.ts and (a.t0=b.t0 and a.t0 > b.t0);") + tdSql.checkRows(0) # tdSql.checkData(0,1,10)