enh: support desc join

This commit is contained in:
dapan1121 2024-03-08 16:23:41 +08:00
parent 46ea22eecb
commit 3f36f7ea52
10 changed files with 1207 additions and 212 deletions

View File

@ -230,6 +230,8 @@ typedef struct SMJoinWinCache {
SSDataBlock* outBlk; SSDataBlock* outBlk;
} SMJoinWinCache; } SMJoinWinCache;
typedef int32_t (*joinMoveWin)(void*);
typedef struct SMJoinWindowCtx { typedef struct SMJoinWindowCtx {
// KEEP IT FIRST // KEEP IT FIRST
struct SMJoinOperatorInfo* pJoin; struct SMJoinOperatorInfo* pJoin;
@ -250,9 +252,12 @@ typedef struct SMJoinWindowCtx {
bool lowerRowsAcq; bool lowerRowsAcq;
bool eqRowsAcq; bool eqRowsAcq;
bool greaterRowsAcq; bool greaterRowsAcq;
bool forwardRowsAcq;
int64_t winBeginTs; int64_t winBeginTs;
int64_t winEndTs; int64_t winEndTs;
joinMoveWin moveWinBeginFp;
joinMoveWin moveWinEndFp;
bool eqPostDone; bool eqPostDone;
int64_t lastTs; int64_t lastTs;
SMJoinGrpRows probeGrp; SMJoinGrpRows probeGrp;
@ -321,8 +326,9 @@ typedef struct SMJoinOperatorInfo {
#define SET_SAME_TS_GRP_HJOIN(_pair, _octx) ((_pair)->hashJoin = (_octx)->hashCan && REACH_HJOIN_THRESHOLD(_pair)) #define SET_SAME_TS_GRP_HJOIN(_pair, _octx) ((_pair)->hashJoin = (_octx)->hashCan && REACH_HJOIN_THRESHOLD(_pair))
#define PROBE_TS_LOWER(_order, _pts, _bts) ((_order) && (_pts) < (_bts)) || (!(_order) && (_pts) > (_bts)) #define PROBE_TS_NMATCH(_asc, _pts, _bts) (((_asc) && (_pts) < (_bts)) || (!(_asc) && (_pts) > (_bts)))
#define PROBE_TS_GREATER(_order, _pts, _bts) ((_order) && (_pts) > (_bts)) || (!(_order) && (_pts) < (_bts)) #define PROBE_TS_NREACH(_asc, _pts, _bts) (((_asc) && (_pts) > (_bts)) || (!(_asc) && (_pts) < (_bts)))
#define MJOIN_BUILD_BLK_OOR(_asc, _pts, _pidx, _bts, _bnum) (((_asc) && (*((int64_t*)(_pts) + (_pidx)) > *((int64_t*)(_bts) + (_bnum) - 1))) || ((!(_asc)) && (*((int64_t*)(_pts) + (_pidx)) < *((int64_t*)(_bts) + (_bnum) - 1))))
#define GRP_REMAIN_ROWS(_grp) ((_grp)->endIdx - (_grp)->readIdx + 1) #define GRP_REMAIN_ROWS(_grp) ((_grp)->endIdx - (_grp)->readIdx + 1)
#define GRP_DONE(_grp) ((_grp)->readIdx > (_grp)->endIdx) #define GRP_DONE(_grp) ((_grp)->readIdx > (_grp)->endIdx)

File diff suppressed because it is too large Load Diff

View File

@ -633,7 +633,7 @@ int32_t mJoinProcessLowerGrp(SMJoinMergeCtx* pCtx, SMJoinTableCtx* pTb, SColumnI
while (++pTb->blkRowIdx < pTb->blk->info.rows) { while (++pTb->blkRowIdx < pTb->blk->info.rows) {
MJOIN_GET_TB_CUR_TS(pCol, *probeTs, pTb); MJOIN_GET_TB_CUR_TS(pCol, *probeTs, pTb);
if (PROBE_TS_LOWER(pCtx->ascTs, *probeTs, *buildTs)) { if (PROBE_TS_NMATCH(pCtx->ascTs, *probeTs, *buildTs)) {
pCtx->probeNEqGrp.endIdx = pTb->blkRowIdx; pCtx->probeNEqGrp.endIdx = pTb->blkRowIdx;
continue; continue;
} }
@ -652,7 +652,7 @@ int32_t mJoinProcessGreaterGrp(SMJoinMergeCtx* pCtx, SMJoinTableCtx* pTb, SColum
while (++pTb->blkRowIdx < pTb->blk->info.rows) { while (++pTb->blkRowIdx < pTb->blk->info.rows) {
MJOIN_GET_TB_CUR_TS(pCol, *buildTs, pTb); MJOIN_GET_TB_CUR_TS(pCol, *buildTs, pTb);
if (PROBE_TS_GREATER(pCtx->ascTs, *probeTs, *buildTs)) { if (PROBE_TS_NREACH(pCtx->ascTs, *probeTs, *buildTs)) {
pCtx->buildNEqGrp.endIdx = pTb->blkRowIdx; pCtx->buildNEqGrp.endIdx = pTb->blkRowIdx;
continue; continue;
} }

View File

@ -66,7 +66,7 @@ enum {
}; };
#define COL_DISPLAY_WIDTH 18 #define COL_DISPLAY_WIDTH 18
#define JT_MAX_LOOP 20000 #define JT_MAX_LOOP 5000
#define LEFT_BLK_ID 0 #define LEFT_BLK_ID 0
#define RIGHT_BLK_ID 1 #define RIGHT_BLK_ID 1
@ -957,7 +957,7 @@ void appendAllAsofResRows() {
taosArrayClear(jtCtx.leftRowsList); taosArrayClear(jtCtx.leftRowsList);
} }
void chkAppendAsofGreaterResRows(bool forceOut) { void chkAppendAsofForwardGrpResRows(bool forceOut) {
int32_t rightRows = taosArrayGetSize(jtCtx.rightRowsList); int32_t rightRows = taosArrayGetSize(jtCtx.rightRowsList);
if (rightRows < jtCtx.jLimit && !forceOut) { if (rightRows < jtCtx.jLimit && !forceOut) {
return; return;
@ -974,7 +974,7 @@ void chkAppendAsofGreaterResRows(bool forceOut) {
for (int32_t r = rightOffset; r < rightRows; ++r) { for (int32_t r = rightOffset; r < rightRows; ++r) {
char* rightRow = (char*)taosArrayGet(jtCtx.rightRowsList, r); char* rightRow = (char*)taosArrayGet(jtCtx.rightRowsList, r);
int64_t* rightTs = (int64_t*)(rightRow + jtCtx.inColOffset[JT_PRIM_TS_SLOT_ID]); int64_t* rightTs = (int64_t*)(rightRow + jtCtx.inColOffset[JT_PRIM_TS_SLOT_ID]);
if ((*leftTs > *rightTs) || (*leftTs == *rightTs && OP_TYPE_LOWER_THAN == jtCtx.asofOpType)) { if (((jtCtx.asc && *leftTs > *rightTs) || (!jtCtx.asc && *leftTs < *rightTs)) || (*leftTs == *rightTs && (OP_TYPE_LOWER_THAN == jtCtx.asofOpType || OP_TYPE_GREATER_THAN == jtCtx.asofOpType))) {
rightOffset++; rightOffset++;
rightRemains--; rightRemains--;
if (rightRemains < jtCtx.jLimit && !forceOut) { if (rightRemains < jtCtx.jLimit && !forceOut) {
@ -1031,7 +1031,8 @@ void appendWinEachResGrps(char* leftInRow, int32_t rightOffset, int32_t rightRow
} }
int32_t endIdx = rightRows + rightOffset; int32_t endIdx = rightRows + rightOffset;
for (int32_t r = rightOffset; r < endIdx; ++r) { int32_t beginIdx = (!jtCtx.asc && rightRows > jtCtx.jLimit) ? (endIdx - jtCtx.jLimit) : rightOffset;
for (int32_t r = beginIdx; r < endIdx; ++r) {
bool* rightFilterOut = (bool*)taosArrayGet(jtCtx.rightFilterOut, r); bool* rightFilterOut = (bool*)taosArrayGet(jtCtx.rightFilterOut, r);
if (*rightFilterOut) { if (*rightFilterOut) {
continue; continue;
@ -1075,7 +1076,7 @@ void chkAppendWinResRows(bool forceOut) {
for (int32_t r = rightOffset; r < rightRows; ++r) { for (int32_t r = rightOffset; r < rightRows; ++r) {
char* rightRow = (char*)taosArrayGet(jtCtx.rightRowsList, r); char* rightRow = (char*)taosArrayGet(jtCtx.rightRowsList, r);
int64_t* rightTs = (int64_t*)(rightRow + jtCtx.inColOffset[JT_PRIM_TS_SLOT_ID]); int64_t* rightTs = (int64_t*)(rightRow + jtCtx.inColOffset[JT_PRIM_TS_SLOT_ID]);
if (*rightTs < winStart) { if ((jtCtx.asc && *rightTs < winStart) || (!jtCtx.asc && *rightTs > winEnd)) {
rightOffset++; rightOffset++;
rightRemains--; rightRemains--;
if (rightRemains < jtCtx.jLimit && !forceOut) { if (rightRemains < jtCtx.jLimit && !forceOut) {
@ -1086,7 +1087,7 @@ void chkAppendWinResRows(bool forceOut) {
} }
continue; continue;
} else if (*rightTs > winEnd) { } else if ((jtCtx.asc && *rightTs > winEnd) || (!jtCtx.asc && *rightTs < winStart)) {
winClosed = true; winClosed = true;
appendWinEachResGrps(leftRow, winBeginIdx, r - winBeginIdx); appendWinEachResGrps(leftRow, winBeginIdx, r - winBeginIdx);
append = true; append = true;
@ -1097,7 +1098,7 @@ void chkAppendWinResRows(bool forceOut) {
winBeginIdx = r; winBeginIdx = r;
} }
if ((r - winBeginIdx + 1) >= jtCtx.jLimit) { if (jtCtx.asc && (r - winBeginIdx + 1) >= jtCtx.jLimit) {
appendWinEachResGrps(leftRow, winBeginIdx, jtCtx.jLimit); appendWinEachResGrps(leftRow, winBeginIdx, jtCtx.jLimit);
append = true; append = true;
break; break;
@ -1213,7 +1214,7 @@ void createGrpRows(SSDataBlock** ppBlk, int32_t blkId, int32_t grpRows) {
for (int32_t c = 0; c < MAX_SLOT_NUM; ++c) { for (int32_t c = 0; c < MAX_SLOT_NUM; ++c) {
switch (jtInputColType[c]) { switch (jtInputColType[c]) {
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
++jtCtx.curTs; jtCtx.asc ? ++jtCtx.curTs : --jtCtx.curTs;
pData = (char*)&jtCtx.curTs; pData = (char*)&jtCtx.curTs;
isNull = false; isNull = false;
if (!filterOut && filterNum && filterCol[c] && jtCtx.curTs <= TIMESTAMP_FILTER_VALUE) { if (!filterOut && filterNum && filterCol[c] && jtCtx.curTs <= TIMESTAMP_FILTER_VALUE) {
@ -1292,14 +1293,14 @@ void createGrpRows(SSDataBlock** ppBlk, int32_t blkId, int32_t grpRows) {
if (keepInput) { if (keepInput) {
if (JOIN_STYPE_ASOF == jtCtx.subType) { if (JOIN_STYPE_ASOF == jtCtx.subType) {
if (jtCtx.asofOpType == OP_TYPE_GREATER_EQUAL || jtCtx.asofOpType == OP_TYPE_GREATER_THAN || jtCtx.asofOpType == OP_TYPE_EQUAL) { if (((jtCtx.asc && (jtCtx.asofOpType == OP_TYPE_GREATER_EQUAL || jtCtx.asofOpType == OP_TYPE_GREATER_THAN)) || (!jtCtx.asc && (jtCtx.asofOpType == OP_TYPE_LOWER_EQUAL || jtCtx.asofOpType == OP_TYPE_LOWER_THAN)) ) || jtCtx.asofOpType == OP_TYPE_EQUAL) {
if (blkId == LEFT_BLK_ID) { if (blkId == LEFT_BLK_ID) {
appendAllAsofResRows(); appendAllAsofResRows();
} else { } else {
trimForAsofJlimit(); trimForAsofJlimit();
} }
} else { } else {
chkAppendAsofGreaterResRows(false); chkAppendAsofForwardGrpResRows(false);
} }
} else { } else {
chkAppendWinResRows(false); chkAppendWinResRows(false);
@ -1965,7 +1966,7 @@ void addAsofEqInRows(int32_t rowsNum, int64_t tbOffset, bool leftTable) {
} }
} }
if (!leftTable && (jtCtx.asofOpType == OP_TYPE_GREATER_EQUAL || jtCtx.asofOpType == OP_TYPE_GREATER_THAN || jtCtx.asofOpType == OP_TYPE_EQUAL)) { if (!leftTable && ((jtCtx.asc && (jtCtx.asofOpType == OP_TYPE_GREATER_EQUAL || jtCtx.asofOpType == OP_TYPE_GREATER_THAN)) || (!jtCtx.asc && (jtCtx.asofOpType == OP_TYPE_LOWER_EQUAL || jtCtx.asofOpType == OP_TYPE_LOWER_THAN))) || jtCtx.asofOpType == OP_TYPE_EQUAL) {
trimForAsofJlimit(); trimForAsofJlimit();
} }
} }
@ -1973,22 +1974,58 @@ void addAsofEqInRows(int32_t rowsNum, int64_t tbOffset, bool leftTable) {
void asofJoinAppendEqGrpRes(int32_t leftGrpRows, int32_t rightGrpRows) { void asofJoinAppendEqGrpRes(int32_t leftGrpRows, int32_t rightGrpRows) {
int64_t rightTbOffset = jtCtx.blkRowSize * leftGrpRows; int64_t rightTbOffset = jtCtx.blkRowSize * leftGrpRows;
if (jtCtx.asc) {
switch (jtCtx.asofOpType) {
case OP_TYPE_GREATER_THAN:
addAsofEqInRows(leftGrpRows, 0, true);
appendAllAsofResRows();
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
break;
case OP_TYPE_GREATER_EQUAL:
addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
appendAllAsofResRows();
break;
case OP_TYPE_LOWER_THAN:
case OP_TYPE_LOWER_EQUAL:
addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
chkAppendAsofForwardGrpResRows(false);
break;
case OP_TYPE_EQUAL:
taosArrayClear(jtCtx.leftRowsList);
taosArrayClear(jtCtx.rightRowsList);
taosArrayClear(jtCtx.rightFilterOut);
addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
chkAppendAsofForwardGrpResRows(true);
taosArrayClear(jtCtx.leftRowsList);
taosArrayClear(jtCtx.rightRowsList);
taosArrayClear(jtCtx.rightFilterOut);
break;
default:
return;
}
return;
}
switch (jtCtx.asofOpType) { switch (jtCtx.asofOpType) {
case OP_TYPE_GREATER_THAN:
addAsofEqInRows(leftGrpRows, 0, true);
appendAllAsofResRows();
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
break;
case OP_TYPE_GREATER_EQUAL:
addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
appendAllAsofResRows();
break;
case OP_TYPE_LOWER_THAN: case OP_TYPE_LOWER_THAN:
addAsofEqInRows(leftGrpRows, 0, true);
appendAllAsofResRows();
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
break;
case OP_TYPE_LOWER_EQUAL: case OP_TYPE_LOWER_EQUAL:
addAsofEqInRows(leftGrpRows, 0, true); addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false); addAsofEqInRows(rightGrpRows, rightTbOffset, false);
chkAppendAsofGreaterResRows(false); appendAllAsofResRows();
break;
case OP_TYPE_GREATER_THAN:
case OP_TYPE_GREATER_EQUAL:
addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false);
chkAppendAsofForwardGrpResRows(false);
break; break;
case OP_TYPE_EQUAL: case OP_TYPE_EQUAL:
taosArrayClear(jtCtx.leftRowsList); taosArrayClear(jtCtx.leftRowsList);
@ -1996,7 +2033,7 @@ void asofJoinAppendEqGrpRes(int32_t leftGrpRows, int32_t rightGrpRows) {
taosArrayClear(jtCtx.rightFilterOut); taosArrayClear(jtCtx.rightFilterOut);
addAsofEqInRows(leftGrpRows, 0, true); addAsofEqInRows(leftGrpRows, 0, true);
addAsofEqInRows(rightGrpRows, rightTbOffset, false); addAsofEqInRows(rightGrpRows, rightTbOffset, false);
chkAppendAsofGreaterResRows(true); chkAppendAsofForwardGrpResRows(true);
taosArrayClear(jtCtx.leftRowsList); taosArrayClear(jtCtx.leftRowsList);
taosArrayClear(jtCtx.rightRowsList); taosArrayClear(jtCtx.rightRowsList);
taosArrayClear(jtCtx.rightFilterOut); taosArrayClear(jtCtx.rightFilterOut);
@ -2227,7 +2264,7 @@ void createTsEqGrpRows(SSDataBlock** ppLeft, SSDataBlock** ppRight, int32_t left
jtCtx.inputStat |= (1 << 2); jtCtx.inputStat |= (1 << 2);
} }
++jtCtx.curTs; jtCtx.asc ? ++jtCtx.curTs : --jtCtx.curTs;
if (NULL == *ppLeft && leftGrpRows > 0) { if (NULL == *ppLeft && leftGrpRows > 0) {
*ppLeft = createDummyBlock(LEFT_BLK_ID); *ppLeft = createDummyBlock(LEFT_BLK_ID);
@ -2257,8 +2294,9 @@ void createTsEqGrpRows(SSDataBlock** ppLeft, SSDataBlock** ppRight, int32_t left
void forceFlushResRows() { void forceFlushResRows() {
if (JOIN_STYPE_ASOF == jtCtx.subType && taosArrayGetSize(jtCtx.leftRowsList) > 0) { if (JOIN_STYPE_ASOF == jtCtx.subType && taosArrayGetSize(jtCtx.leftRowsList) > 0) {
ASSERT(OP_TYPE_LOWER_EQUAL == jtCtx.asofOpType || OP_TYPE_LOWER_THAN == jtCtx.asofOpType); ASSERT((jtCtx.asc && (OP_TYPE_LOWER_EQUAL == jtCtx.asofOpType || OP_TYPE_LOWER_THAN == jtCtx.asofOpType))
chkAppendAsofGreaterResRows(true); || (!jtCtx.asc && (OP_TYPE_GREATER_EQUAL == jtCtx.asofOpType || OP_TYPE_GREATER_THAN == jtCtx.asofOpType)));
chkAppendAsofForwardGrpResRows(true);
} else if (JOIN_STYPE_WIN == jtCtx.subType && taosArrayGetSize(jtCtx.leftRowsList) > 0) { } else if (JOIN_STYPE_WIN == jtCtx.subType && taosArrayGetSize(jtCtx.leftRowsList) > 0) {
chkAppendWinResRows(true); chkAppendWinResRows(true);
} }
@ -2277,7 +2315,8 @@ void createBothBlkRowsData(void) {
jtCtx.rightTotalRows = taosRand() % jtCtx.rightMaxRows; jtCtx.rightTotalRows = taosRand() % jtCtx.rightMaxRows;
int32_t minTotalRows = TMIN(jtCtx.leftTotalRows, jtCtx.rightTotalRows); int32_t minTotalRows = TMIN(jtCtx.leftTotalRows, jtCtx.rightTotalRows);
jtCtx.curTs = TIMESTAMP_FILTER_VALUE - minTotalRows / 5; int32_t maxTotalRows = TMAX(jtCtx.leftTotalRows, jtCtx.rightTotalRows);
jtCtx.curTs = jtCtx.asc ? (TIMESTAMP_FILTER_VALUE - minTotalRows / 5) : (TIMESTAMP_FILTER_VALUE + 4 * maxTotalRows / 5);
int32_t leftTotalRows = 0, rightTotalRows = 0; int32_t leftTotalRows = 0, rightTotalRows = 0;
int32_t leftGrpRows = 0, rightGrpRows = 0; int32_t leftGrpRows = 0, rightGrpRows = 0;
@ -2463,8 +2502,8 @@ void printInputData() {
printInputRowData(pBlk, &leftRowIdx); printInputRowData(pBlk, &leftRowIdx);
break; break;
} }
printf("\t--------------------------blk end------------------------------- "); printf("\t%*s-------------------------blk end-------------------------------", jtCtx.grpJoin ? 6 : 0, " ");
jtCtx.leftBlkReadIdx++; jtCtx.leftBlkReadIdx++;
leftRowIdx = 0; leftRowIdx = 0;
break; break;
@ -2481,7 +2520,7 @@ void printInputData() {
break; break;
} }
printf("\t%*s--------------------------blk end----------------------------\t", jtCtx.grpJoin ? 5 : 0, " "); printf("\t%*s--------------------------blk end----------------------------\t", jtCtx.grpJoin ? 6 : 0, " ");
jtCtx.rightBlkReadIdx++; jtCtx.rightBlkReadIdx++;
rightRowIdx = 0; rightRowIdx = 0;
break; break;
@ -2801,7 +2840,7 @@ void runSingleTest(char* caseName, SJoinTestParam* param) {
bool contLoop = true; bool contLoop = true;
SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param); SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param);
createDummyBlkList(12, 3, 12, 3, 3); createDummyBlkList(100, 10, 100, 10, 10);
while (contLoop) { while (contLoop) {
rerunBlockedHere(); rerunBlockedHere();
@ -2848,6 +2887,7 @@ TEST(innerJoin, noCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -2874,6 +2914,7 @@ TEST(innerJoin, eqCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -2900,6 +2941,7 @@ TEST(innerJoin, onCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -2926,6 +2968,7 @@ TEST(innerJoin, fullCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -2954,6 +2997,7 @@ TEST(leftOuterJoin, noCondTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -2982,6 +3026,7 @@ TEST(leftOuterJoin, eqCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3008,6 +3053,7 @@ TEST(leftOuterJoin, onCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3034,6 +3080,7 @@ TEST(leftOuterJoin, fullCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3062,6 +3109,7 @@ TEST(fullOuterJoin, noCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3088,6 +3136,7 @@ TEST(fullOuterJoin, eqCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3115,6 +3164,7 @@ TEST(fullOuterJoin, onCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3141,6 +3191,7 @@ TEST(fullOuterJoin, fullCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3169,6 +3220,7 @@ TEST(leftSemiJoin, noCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3195,6 +3247,7 @@ TEST(leftSemiJoin, eqCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3222,6 +3275,7 @@ TEST(leftSemiJoin, onCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3248,6 +3302,7 @@ TEST(leftSemiJoin, fullCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3276,6 +3331,7 @@ TEST(leftAntiJoin, noCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3302,6 +3358,7 @@ TEST(leftAntiJoin, eqCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3329,6 +3386,7 @@ TEST(leftAntiJoin, onCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3355,6 +3413,7 @@ TEST(leftAntiJoin, fullCondTest) {
param.grpJoin = false; param.grpJoin = false;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.filter = false; param.filter = false;
runSingleTest(caseName, &param); runSingleTest(caseName, &param);
@ -3383,6 +3442,7 @@ TEST(leftAsofJoin, noCondGreaterThanTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
@ -3413,6 +3473,7 @@ TEST(leftAsofJoin, noCondGreaterEqTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
@ -3443,6 +3504,7 @@ TEST(leftAsofJoin, noCondEqTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
@ -3473,6 +3535,7 @@ TEST(leftAsofJoin, noCondLowerThanTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
@ -3504,6 +3567,7 @@ TEST(leftAsofJoin, noCondLowerEqTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;
@ -3537,6 +3601,7 @@ TEST(leftWinJoin, noCondProjectionTest) {
param.asc = true; param.asc = true;
for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) { for (jtCtx.loopIdx = 0; jtCtx.loopIdx < JT_MAX_LOOP; ++jtCtx.loopIdx) {
param.asc = !param.asc;
param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1; param.jLimit = taosRand() % 2 ? (1 + (taosRand() % JT_MAX_JLIMIT)) : 1;
param.grpJoin = taosRand() % 2 ? true : false; param.grpJoin = taosRand() % 2 ? true : false;

View File

@ -134,4 +134,39 @@ if $data13 != 3 then
return -1 return -1
endi endi
sql select a.ts, b.ts from sta a join sta b on a.ts=b.ts order by a.ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a join sta b on a.ts=b.ts order by b.ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi

View File

@ -86,3 +86,36 @@ if $data11 != NULL then
return -1 return -1
endi endi
sql select a.ts, b.ts from tba1 a left anti join tba2 b on a.ts = b.ts order by a.ts desc;
if $rows != 2 then
return -1
endi
if $data00 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:02.000@ then
return -1
endi
if $data11 != NULL then
return -1
endi
sql select a.ts, b.ts from sta a left anti join sta b on a.ts = b.ts and b.ts < '2023-11-17 16:29:03.000' order by a.ts desc;
if $rows != 4 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != NULL then
return -1
endi

View File

@ -977,6 +977,188 @@ if $rows != 10 then
return -1 return -1
endi endi
sql select a.ts, b.ts from sta a left asof join sta b order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b jlimit 2 order by a.ts desc;
if $rows != 16 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data30 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data31 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts > b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts > b.ts jlimit 2 order by a.ts desc;
if $rows != 14 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts <= b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts <= b.ts jlimit 2 order by a.ts desc;
if $rows != 15 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:05.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts < b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:05.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts < b.ts jlimit 2 order by a.ts desc;
if $rows != 14 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:05.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts = b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left asof join sta b on a.ts = b.ts jlimit 2 order by a.ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql_error select a.ts, b.ts from sta a asof join sta b on a.ts = b.ts; sql_error select a.ts, b.ts from sta a asof join sta b on a.ts = b.ts;
sql_error select a.ts, b.ts from sta a full asof join sta b on a.ts = b.ts; sql_error select a.ts, b.ts from sta a full asof join sta b on a.ts = b.ts;
sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts != b.ts; sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts != b.ts;

View File

@ -158,3 +158,49 @@ if $data31 != NULL then
return -1 return -1
endi endi
sql select a.ts, b.ts from tba2 a left join tba1 b on a.ts = b.ts order by a.ts desc;
if $rows != 4 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:01.000@ then
return -1
endi
if $data21 != NULL then
return -1
endi
if $data30 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data31 != @23-11-17 16:29:00.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left join sta b on a.ts=b.ts order by a.ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi

View File

@ -74,6 +74,41 @@ if $data11 != 4 then
return -1 return -1
endi endi
sql select a.ts, b.ts from tba1 a left semi join tba2 b on a.ts = b.ts order by a.ts desc;
if $rows != 2 then
return -1
endi
if $data00 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:00.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left semi join sta b on a.ts = b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql_error select a.ts, b.ts from sta a left semi join sta b jlimit 3 where a.ts > b.ts; sql_error select a.ts, b.ts from sta a left semi join sta b jlimit 3 where a.ts > b.ts;
sql_error select a.ts, b.ts from sta a left semi join sta b where a.ts > b.ts; sql_error select a.ts, b.ts from sta a left semi join sta b where a.ts > b.ts;
sql_error select a.ts, b.ts from sta a left semi join sta b on a.ts > 1 where a.ts = b.ts; sql_error select a.ts, b.ts from sta a left semi join sta b on a.ts > 1 where a.ts = b.ts;

View File

@ -624,6 +624,322 @@ if $data31 != 1 then
return -1 return -1
endi endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(-2s, -1s) order by a.ts desc;
if $rows != 17 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(-2s, -1s) jlimit 1 order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:02.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:01.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(-2s, -1s) jlimit 1;
if $rows != 8 then
return -1
endi
if $data50 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data51 != @23-11-17 16:29:01.000@ then
return -1
endi
if $data60 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data61 != @23-11-17 16:29:02.000@ then
return -1
endi
if $data70 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data71 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(0s, 0s) order by a.ts desc;
if $rows != 12 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(-1s, 1s) order by a.ts desc;
if $rows != 28 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:05.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(1s, 2s) order by a.ts desc;
if $rows != 16 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:05.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b window_offset(1s, 2s) jlimit 1 order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b on a.t1=b.t1 window_offset(-2s, -1s) order by a.ts desc, b.ts;
if $rows != 9 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:02.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b on a.t1=b.t1 window_offset(0s, 0s) order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:03.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b on a.t1=b.t1 window_offset(-1s, 1s) order by a.ts desc, b.ts desc;
if $rows != 14 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data30 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data31 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left window join sta b on a.t1=b.t1 window_offset(1s, 2s) order by a.ts desc, b.ts desc;
if $rows != 9 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != NULL then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != NULL then
return -1
endi
if $data20 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data30 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data31 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select count(*) from sta a left window join sta b on a.t1=b.t1 window_offset(1s, 2s) order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 1 then
return -1
endi
if $data30 != 1 then
return -1
endi
if $data40 != 2 then
return -1
endi
if $data50 != 1 then
return -1
endi
if $data60 != 1 then
return -1
endi
if $data70 != 1 then
return -1
endi
sql select count(b.ts) from sta a left window join sta b on a.t1=b.t1 window_offset(1s, 2s) order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data10 != 0 then
return -1
endi
if $data20 != 1 then
return -1
endi
if $data30 != 1 then
return -1
endi
if $data40 != 2 then
return -1
endi
if $data50 != 1 then
return -1
endi
if $data60 != 1 then
return -1
endi
if $data70 != 1 then
return -1
endi
sql_error select a.col1, count(*) from sta a left window join sta b window_offset(-1s, 1s); sql_error select a.col1, count(*) from sta a left window join sta b window_offset(-1s, 1s);
sql_error select b.ts, count(*) from sta a left window join sta b window_offset(-1s, 1s); sql_error select b.ts, count(*) from sta a left window join sta b window_offset(-1s, 1s);
sql_error select a.ts, b.ts from sta a left window join sta b window_offset(-1s, 1s) having(b.ts > 0); sql_error select a.ts, b.ts from sta a left window join sta b window_offset(-1s, 1s) having(b.ts > 0);