From 6d4f0b2ceb9e8839c10ddb6372d63c94723817e4 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 15 Apr 2024 16:12:12 +0800 Subject: [PATCH] fix: asof jlimit issue --- source/libs/executor/src/mergejoin.c | 1 + source/libs/executor/test/joinTests.cpp | 4 ++-- source/libs/parser/src/parTranslater.c | 5 ++++- tests/script/tsim/join/join_scalar1.sim | 8 ++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/libs/executor/src/mergejoin.c b/source/libs/executor/src/mergejoin.c index 2ba1a5d376..df8c6e2faf 100755 --- a/source/libs/executor/src/mergejoin.c +++ b/source/libs/executor/src/mergejoin.c @@ -2591,6 +2591,7 @@ SSDataBlock* mAsofForwardJoinDo(struct SOperatorInfo* pOperator) { if (PROBE_TS_NMATCH(pCtx->ascTs, probeTs, buildTs)) { MJ_ERR_JRET(mAsofForwardHandleProbeGrp(pCtx, pJoin, pProbeCol, &probeTs, &buildTs)); + MJOIN_GET_TB_COL_TS(pBuildCol, buildTs, pJoin->build); } else { MJ_ERR_JRET(mAsofForwardSkipBuildGrp(pCtx, pJoin, &pBuildCol, &probeTs, &buildTs)); } diff --git a/source/libs/executor/test/joinTests.cpp b/source/libs/executor/test/joinTests.cpp index a45e25f597..d092848fc3 100755 --- a/source/libs/executor/test/joinTests.cpp +++ b/source/libs/executor/test/joinTests.cpp @@ -66,7 +66,7 @@ enum { }; #define COL_DISPLAY_WIDTH 18 -#define JT_MAX_LOOP 100000 +#define JT_MAX_LOOP 1000 #define LEFT_BLK_ID 0 #define RIGHT_BLK_ID 1 @@ -2862,7 +2862,7 @@ void runSingleTest(char* caseName, SJoinTestParam* param) { bool contLoop = true; SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param); - createDummyBlkList(10000, 10000, 10000, 10000, 4096); + createDummyBlkList(1000, 1000, 1000, 1000, 100); while (contLoop) { rerunBlockedHere(); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 731dfbe1c3..f236cad6da 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3851,9 +3851,12 @@ static int32_t translateJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoin return buildInvalidOperationMsgExt(&pCxt->msgBuf, "JLIMIT not supported for %s join", getFullJoinTypeString(type, *pSType)); } SLimitNode* pJLimit = (SLimitNode*)pJoinTable->pJLimit; - if (pJLimit->limit > JOIN_JLIMIT_MAX_VALUE) { + if (pJLimit->limit > JOIN_JLIMIT_MAX_VALUE || pJLimit->limit < 0) { return buildInvalidOperationMsg(&pCxt->msgBuf, "JLIMIT value is out of valid range [0, 1024]"); } + if (0 == pJLimit->limit) { + pCurrSmt->isEmptyResult = true; + } } return code; diff --git a/tests/script/tsim/join/join_scalar1.sim b/tests/script/tsim/join/join_scalar1.sim index dc355ddc88..d2c7d355a9 100644 --- a/tests/script/tsim/join/join_scalar1.sim +++ b/tests/script/tsim/join/join_scalar1.sim @@ -46,6 +46,10 @@ sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h if $rows != 8 then return -1 endi +sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 0; +if $rows != 0 then + return -1 +endi sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2; if $rows != 16 then return -1 @@ -1136,6 +1140,10 @@ endi if $data70 != 1 then return -1 endi +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) jlimit 0 order by a.tbname, a.ts; +if $rows != 0 then + return -1 +endi sql select count(b.col1) from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname, a.ts; if $rows != 8 then return -1