fix: asof jlimit issue

This commit is contained in:
dapan1121 2024-04-15 16:12:12 +08:00
parent 45b1a64a97
commit 6d4f0b2ceb
4 changed files with 15 additions and 3 deletions

View File

@ -2591,6 +2591,7 @@ SSDataBlock* mAsofForwardJoinDo(struct SOperatorInfo* pOperator) {
if (PROBE_TS_NMATCH(pCtx->ascTs, probeTs, buildTs)) { if (PROBE_TS_NMATCH(pCtx->ascTs, probeTs, buildTs)) {
MJ_ERR_JRET(mAsofForwardHandleProbeGrp(pCtx, pJoin, pProbeCol, &probeTs, &buildTs)); MJ_ERR_JRET(mAsofForwardHandleProbeGrp(pCtx, pJoin, pProbeCol, &probeTs, &buildTs));
MJOIN_GET_TB_COL_TS(pBuildCol, buildTs, pJoin->build);
} else { } else {
MJ_ERR_JRET(mAsofForwardSkipBuildGrp(pCtx, pJoin, &pBuildCol, &probeTs, &buildTs)); MJ_ERR_JRET(mAsofForwardSkipBuildGrp(pCtx, pJoin, &pBuildCol, &probeTs, &buildTs));
} }

View File

@ -66,7 +66,7 @@ enum {
}; };
#define COL_DISPLAY_WIDTH 18 #define COL_DISPLAY_WIDTH 18
#define JT_MAX_LOOP 100000 #define JT_MAX_LOOP 1000
#define LEFT_BLK_ID 0 #define LEFT_BLK_ID 0
#define RIGHT_BLK_ID 1 #define RIGHT_BLK_ID 1
@ -2862,7 +2862,7 @@ void runSingleTest(char* caseName, SJoinTestParam* param) {
bool contLoop = true; bool contLoop = true;
SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param); SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param);
createDummyBlkList(10000, 10000, 10000, 10000, 4096); createDummyBlkList(1000, 1000, 1000, 1000, 100);
while (contLoop) { while (contLoop) {
rerunBlockedHere(); rerunBlockedHere();

View File

@ -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)); return buildInvalidOperationMsgExt(&pCxt->msgBuf, "JLIMIT not supported for %s join", getFullJoinTypeString(type, *pSType));
} }
SLimitNode* pJLimit = (SLimitNode*)pJoinTable->pJLimit; 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]"); return buildInvalidOperationMsg(&pCxt->msgBuf, "JLIMIT value is out of valid range [0, 1024]");
} }
if (0 == pJLimit->limit) {
pCurrSmt->isEmptyResult = true;
}
} }
return code; return code;

View File

@ -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 if $rows != 8 then
return -1 return -1
endi 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; 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 if $rows != 16 then
return -1 return -1
@ -1136,6 +1140,10 @@ endi
if $data70 != 1 then if $data70 != 1 then
return -1 return -1
endi 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; 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 if $rows != 8 then
return -1 return -1