From abd36b0b1a97215690096f38172d082926528ee4 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 19 Mar 2024 16:01:14 +0800 Subject: [PATCH] enh: support timeline processing --- include/libs/nodes/plannodes.h | 1 + source/libs/executor/test/joinTests.cpp | 8 +- source/libs/parser/src/parTranslater.c | 161 +++-- source/libs/planner/inc/planInt.h | 1 + source/libs/planner/src/planOptimizer.c | 12 +- source/libs/planner/src/planSpliter.c | 8 +- tests/script/tsim/join/join_nested.sim | 830 +++++++++++++++++++++++- 7 files changed, 943 insertions(+), 78 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index fbfa763cb7..c3f5382348 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -66,6 +66,7 @@ typedef struct SLogicNode { EOrder inputTsOrder; EOrder outputTsOrder; bool forceCreateNonBlockingOptr; // true if the operator can use non-blocking(pipeline) mode + bool splitDone; } SLogicNode; typedef enum EScanType { diff --git a/source/libs/executor/test/joinTests.cpp b/source/libs/executor/test/joinTests.cpp index d1fd8c2d30..abb95b3f66 100755 --- a/source/libs/executor/test/joinTests.cpp +++ b/source/libs/executor/test/joinTests.cpp @@ -2858,7 +2858,7 @@ void runSingleTest(char* caseName, SJoinTestParam* param) { bool contLoop = true; SSortMergeJoinPhysiNode* pNode = createDummySortMergeJoinPhysiNode(param); - createDummyBlkList(10, 10, 10, 10, 3); + createDummyBlkList(10000, 1000, 10000, 1000, 100); while (contLoop) { rerunBlockedHere(); @@ -3224,7 +3224,7 @@ TEST(fullOuterJoin, fullCondTest) { #endif #endif -#if 0 +#if 1 #if 1 TEST(leftSemiJoin, noCondTest) { SJoinTestParam param; @@ -3335,7 +3335,7 @@ TEST(leftSemiJoin, fullCondTest) { #endif #endif -#if 0 +#if 1 #if 1 TEST(leftAntiJoin, noCondTest) { SJoinTestParam param; @@ -3446,7 +3446,7 @@ TEST(leftAntiJoin, fullCondTest) { #endif #endif -#if 0 +#if 1 #if 1 TEST(leftAsofJoin, noCondGreaterThanTest) { SJoinTestParam param; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ab41b55a0c..413d62ef09 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -858,6 +858,18 @@ static SNodeList* getProjectList(const SNode* pNode) { return NULL; } +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); + } else if (QUERY_NODE_SET_OPERATOR == nodeType(pStmt)) { + return TIME_LINE_GLOBAL == ((SSetOperator*)pStmt)->timeLineResMode; + } else { + return false; + } +} + static bool isTimeLineQuery(SNode* pStmt) { if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { return (TIME_LINE_MULTI == ((SSelectStmt*)pStmt)->timeLineResMode) || @@ -879,11 +891,24 @@ static bool isGlobalTimeLineQuery(SNode* pStmt) { } } -static bool isTimeLineAlignedQuery(SNode* pStmt) { +static bool isBlockTimeLineAlignedQuery(SNode* pStmt) { SSelectStmt* pSelect = (SSelectStmt*)pStmt; - if (isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + if (!isBlockTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + return false; + } + if (QUERY_NODE_SELECT_STMT != nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + return false; + } + SSelectStmt* pSub = (SSelectStmt*)((STempTableNode*)pSelect->pFromTable)->pSubquery; + if (nodesListMatch(pSelect->pPartitionByList, pSub->pPartitionByList)) { return true; } + return false; +} + + +static bool isTimeLineAlignedQuery(SNode* pStmt) { + SSelectStmt* pSelect = (SSelectStmt*)pStmt; if (!isTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { return false; } @@ -969,7 +994,7 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum taosArrayPush(pExpr->pAssociation, &assNode); strcpy(pCol->tableAlias, pTable->table.tableAlias); - pCol->isPrimTs = isPrimaryKey(pTable, (SNode*)pExpr); + pCol->isPrimTs = isPrimaryKeyImpl((SNode*)pExpr); pCol->colId = pCol->isPrimTs ? PRIMARYKEY_TIMESTAMP_COL_ID : 0; strcpy(pCol->colName, pExpr->aliasName); if ('\0' == pCol->node.aliasName[0]) { @@ -981,47 +1006,7 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum pCol->node.resType = pExpr->resType; } -static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList) { - if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { - const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; - int32_t nums = pMeta->tableInfo.numOfColumns + - (igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0)); - for (int32_t i = 0; i < nums; ++i) { - if (invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) { - pCxt->pParseCxt->hasInvisibleCol = true; - continue; - } - SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); - if (NULL == pCol) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); - } - setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i - pMeta->tableInfo.numOfColumns), pCol); - nodesListAppend(pList, (SNode*)pCol); - } - } else { - STempTableNode* pTempTable = (STempTableNode*)pTable; - SNodeList* pProjectList = getProjectList(pTempTable->pSubquery); - SNode* pNode; - FOREACH(pNode, pProjectList) { - SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); - if (NULL == pCol) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); - } - nodesListAppend(pList, (SNode*)pCol); - SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); - setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); - } - } - return TSDB_CODE_SUCCESS; -} - -static bool isInternalPrimaryKey(const SColumnNode* pCol) { - return PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && - (0 == strcmp(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME) || 0 == strcmp(pCol->colName, C0_PSEUDO_COLUMN_NAME)); -} - - -static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, STableNode* pTable) { +static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, const STableNode* pTable) { if (PRIMARYKEY_TIMESTAMP_COL_ID != pCol->colId) { return; } @@ -1061,6 +1046,49 @@ static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, STableNo } } + +static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList) { + if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { + const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; + int32_t nums = pMeta->tableInfo.numOfColumns + + (igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0)); + for (int32_t i = 0; i < nums; ++i) { + if (invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) { + pCxt->pParseCxt->hasInvisibleCol = true; + continue; + } + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); + } + setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema + i, (i - pMeta->tableInfo.numOfColumns), pCol); + setColumnPrimTs(pCxt, pCol, pTable); + nodesListAppend(pList, (SNode*)pCol); + } + } else { + STempTableNode* pTempTable = (STempTableNode*)pTable; + SNodeList* pProjectList = getProjectList(pTempTable->pSubquery); + SNode* pNode; + FOREACH(pNode, pProjectList) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); + } + nodesListAppend(pList, (SNode*)pCol); + SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); + setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); + } + } + return TSDB_CODE_SUCCESS; +} + +static bool isInternalPrimaryKey(const SColumnNode* pCol) { + return PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && + (0 == strcmp(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME) || 0 == strcmp(pCol->colName, C0_PSEUDO_COLUMN_NAME)); +} + + + static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, STableNode* pTable, bool* pFound, bool keepOriginTable) { SColumnNode* pCol = *pColRef; @@ -1121,7 +1149,7 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, } setColumnInfoByExpr(pTempTable, pExpr, pColRef); *pFound = true; - } else if (isPrimaryKey(pTempTable, pNode) && isInternalPrimaryKey(pCol)) { + } else if (isPrimaryKeyImpl(pNode) && isInternalPrimaryKey(pCol)) { setColumnInfoByExpr(pTempTable, pExpr, pColRef); pCol->isPrimTs = true; *pFound = true; @@ -3459,7 +3487,7 @@ static bool getBothJoinContais(SNode* pLeft, SNode* pRight) { static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTable) { if (JOIN_STYPE_NONE != pJoinTable->subType && getBothJoinContais(pJoinTable->pLeft, pJoinTable->pRight)) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, "Nested join not supported now"); + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, "unsupported nested join type"); } if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { @@ -3787,26 +3815,19 @@ static int32_t setJoinTimeLineResMode(STranslateContext* pCxt) { return TSDB_CODE_SUCCESS; } + if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { + if (joinNonPrimColCondContains(pJoinTable)) { + pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; + } + return TSDB_CODE_SUCCESS; + } + if (pJoinTable->table.singleTable || pJoinTable->hasSubQuery || pJoinTable->isLowLevelJoin) { return TSDB_CODE_SUCCESS; } - switch (pJoinTable->subType) { - case JOIN_STYPE_NONE: { - if (innerJoinTagEqCondContains(pJoinTable, pCurrSmt->pWhere)) { - pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; - } - break; - } - case JOIN_STYPE_ASOF: - case JOIN_STYPE_WIN: { - if (joinNonPrimColCondContains(pJoinTable)) { - pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; - } - break; - } - default: - break; + if (JOIN_STYPE_NONE == pJoinTable->subType && innerJoinTagEqCondContains(pJoinTable, pCurrSmt->pWhere)) { + pCurrSmt->timeLineResMode = TIME_LINE_BLOCK; } return TSDB_CODE_SUCCESS; @@ -4747,13 +4768,23 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType == TSDB_SYSTEM_TABLE) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "WINDOW"); } - if ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && + if (QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) && ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && - ((QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) && TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode) || (QUERY_NODE_INTERVAL_WINDOW == nodeType(pSelect->pWindow) && TIME_LINE_NONE == pSelect->timeLineResMode)))) { + (TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode)))) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); } + + if (QUERY_NODE_INTERVAL_WINDOW == nodeType(pSelect->pWindow) && + ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && + !isBlockTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) && + !isTimeLineAlignedQuery(pCxt->pCurrStmt)) || + (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && + (TIME_LINE_NONE == pSelect->timeLineResMode)))) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY); + } + pCxt->currClause = SQL_CLAUSE_WINDOW; int32_t code = translateExpr(pCxt, &pSelect->pWindow); @@ -5371,7 +5402,7 @@ static void resetResultTimeline(SSelectStmt* pSelect) { } SNode* pOrder = ((SOrderByExprNode*)nodesListGetNode(pSelect->pOrderByList, 0))->pExpr; if ((QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && - isPrimaryKey((STempTableNode*)pSelect->pFromTable, pOrder)) || + isPrimaryKeyImpl(pOrder)) || (QUERY_NODE_TEMP_TABLE != nodeType(pSelect->pFromTable) && isPrimaryKeyImpl(pOrder))) { pSelect->timeLineResMode = TIME_LINE_GLOBAL; } else { diff --git a/source/libs/planner/inc/planInt.h b/source/libs/planner/inc/planInt.h index e27eba62ed..fd3ae94717 100644 --- a/source/libs/planner/inc/planInt.h +++ b/source/libs/planner/inc/planInt.h @@ -66,6 +66,7 @@ bool cloneLimit(SLogicNode* pParent, SLogicNode* pChild, uint8_t cloneWhat); int32_t sortPriKeyOptGetSequencingNodesImpl(SLogicNode* pNode, bool groupSort, SSortLogicNode* pSort, bool* pNotOptimize, SNodeList** pSequencingNodes, bool* keepSort); + #ifdef __cplusplus } #endif diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index ccba6a4a37..498a09c9b5 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -172,7 +172,6 @@ static void optSetParentOrder(SLogicNode* pNode, EOrder order, SLogicNode* pNode switch (nodeType(pNode)) { // for those nodes that will change the order, stop propagating // case QUERY_NODE_LOGIC_PLAN_WINDOW: - case QUERY_NODE_LOGIC_PLAN_JOIN: case QUERY_NODE_LOGIC_PLAN_AGG: case QUERY_NODE_LOGIC_PLAN_SORT: if (pNode == pNodeForcePropagate) { @@ -180,6 +179,9 @@ static void optSetParentOrder(SLogicNode* pNode, EOrder order, SLogicNode* pNode break; } else return; + case QUERY_NODE_LOGIC_PLAN_JOIN: + pNode->outputTsOrder = order; + break; case QUERY_NODE_LOGIC_PLAN_WINDOW: // Window output ts order default to be asc, and changed when doing sort by primary key optimization. // We stop propagate the original order to parents. @@ -1671,6 +1673,8 @@ static int32_t sortPriKeyOptHandleLeftRightJoinSort(SJoinLogicNode* pJoin, SSort SSHashObj* pLeftTables = NULL; SSHashObj* pRightTables = NULL; + bool sortByProbe = true; +/* bool sortByLeft = true, sortByRight = true, sortByProbe = false; collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 0), &pLeftTables); collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 1), &pRightTables); @@ -1700,7 +1704,7 @@ static int32_t sortPriKeyOptHandleLeftRightJoinSort(SJoinLogicNode* pJoin, SSort if ((JOIN_TYPE_LEFT == pJoin->joinType && sortByLeft) || (JOIN_TYPE_RIGHT == pJoin->joinType && sortByRight)) { sortByProbe = true; } - +*/ switch (pJoin->subType) { case JOIN_STYPE_OUTER: { if (sortByProbe) { @@ -2012,10 +2016,10 @@ static bool sortForJoinOptMayBeOptimized(SLogicNode* pNode) { SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1); if (ORDER_ASC != pLeft->outputTsOrder && ORDER_DESC != pLeft->outputTsOrder) { - return false; + pLeft->outputTsOrder = ORDER_ASC; } if (ORDER_ASC != pRight->outputTsOrder && ORDER_DESC != pRight->outputTsOrder) { - return false; + pRight->outputTsOrder = ORDER_ASC; } if (pLeft->outputTsOrder == pRight->outputTsOrder) { diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index e74899dd98..03c85d5b0b 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -183,7 +183,7 @@ static int32_t splMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) { static bool splMatchByNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, FSplFindSplitNode func, void* pInfo) { - if (func(pCxt, pSubplan, pNode, pInfo)) { + if (!pNode->splitDone && func(pCxt, pSubplan, pNode, pInfo)) { return true; } SNode* pChild; @@ -192,7 +192,7 @@ static bool splMatchByNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicN return true; } } - return NULL; + return false; } static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag, FSplFindSplitNode func, void* pInfo) { @@ -1429,7 +1429,8 @@ static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) //if (!pInfo->pSplitNode->dynamicOp) { pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; //} - SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT); + //SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT); + pInfo->pSplitNode->splitDone = true; } return code; } @@ -1499,6 +1500,7 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { break; } + info.pSplitNode->splitDone = true; pCxt->split = true; return code; } diff --git a/tests/script/tsim/join/join_nested.sim b/tests/script/tsim/join/join_nested.sim index d1f8b9144e..3ff4f89d56 100644 --- a/tests/script/tsim/join/join_nested.sim +++ b/tests/script/tsim/join/join_nested.sim @@ -6,12 +6,341 @@ if $rows != 64 then return -1 endi -sql select a.*,b.* from (select * from sta partition by tbname) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; -sql select a.*,b.* from (select * from sta partition by tbname order by ts) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +#inner join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql select a.t1 from (select * from sta partition by tbname order by ts) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi + +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts order by b.ts desc; +if $rows != 12 then + return -1 +endi + +#left join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql select a.t1 from (select * from sta partition by tbname order by ts) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi + +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts order by b.ts desc; +if $rows != 12 then + return -1 +endi + + +#left semi join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql select a.t1 from (select * from sta partition by tbname order by ts) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 8 then + return -1 +endi + +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts order by b.ts desc; +if $rows != 8 then + return -1 +endi + + +#left anti join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql select a.t1 from (select * from sta partition by tbname order by ts) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 0 then + return -1 +endi + +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql select a.t1 from (select * from sta partition by tbname order by ts desc) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts order by b.ts desc; +if $rows != 0 then + return -1 +endi + +#left asof join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a left asof join (select * from sta partition by tbname order by ts) b; +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a left asof join (select * from sta partition by tbname order by ts) b; +sql_error select a.t1 from (select * from sta partition by tbname order by ts) a left asof join (select * from sta partition by tbname order by ts) b; +sql_error select a.t1 from (select * from sta partition by tbname order by ts desc) a left asof join (select * from sta partition by tbname order by ts) b; +sql_error select a.t1 from (select * from sta partition by tbname order by ts desc) a left asof join (select * from sta partition by tbname order by ts) b order by b.ts desc; + +#left window join + non join +sql_error select a.*,b.* from (select * from sta partition by tbname) a left window join (select * from sta partition by tbname order by ts) b window_offset(-1s,1s); +sql_error select a.t1 from (select * from sta partition by tbname order by col1) a left window join (select * from sta partition by tbname order by ts) b window_offset(-1s,1s); +sql_error select a.t1 from (select * from sta partition by tbname order by ts) a left window join (select * from sta partition by tbname order by ts) b window_offset(-1s,1s); +sql_error select a.t1 from (select * from sta partition by tbname order by ts desc) a left window join (select * from sta partition by tbname order by ts) b window_offset(-1s,1s); +sql_error select a.t1 from (select * from sta partition by tbname order by ts desc) a left window join (select * from sta partition by tbname order by ts) b window_offset(-1s,1s) order by b.ts desc; + +#inner join + inner join +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts and tb1.t1=tb2.t1) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql select a.ts from (select tba1.ts from tba1 join tba2 on tba1.ts=tba2.ts) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-11-17 16:29:00.000@ then + return -1 +endi +if $data10 != @23-11-17 16:29:00.000@ then + return -1 +endi +if $data20 != @23-11-17 16:29:03.000@ then + return -1 +endi +if $data30 != @23-11-17 16:29:03.000@ then + return -1 +endi + +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 20 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +if $rows != 20 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +if $rows != 20 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +if $rows != 20 then + return -1 +endi + +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) b on a.ts = b.ts; +if $rows != 36 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) b on a.ts = b.ts; +if $rows != 36 then + return -1 +endi + +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#inner join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a join sta b on a.ts = b.ts; +sql select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a join sta b on a.ts = b.ts; +if $rows != 20 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; +if $rows != 36 then + return -1 +endi +sql_error select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#inner join + left semi join +sql select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a join sta b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a join sta b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a join (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#inner join + left anti join +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a join sta b on a.ts = b.ts; +sql select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a join sta b on a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a join (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#inner join + left asof join +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2 order by tb2.ts) a join sta b on a.ts = b.ts; +sql select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a join sta b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a join (select tb1.ts from sta tb1 left asof join sta tb2 order by tb1.ts desc) b on a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql_error select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left asof join sta tb2 order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left asof join sta tb2) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#inner join + left window join +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb2.ts) a join sta b on a.ts = b.ts; +sql select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a join sta b on a.ts = b.ts; +if $rows != 42 then + return -1 +endi +sql select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a join (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb1.ts desc) b on a.ts = b.ts; +if $rows != 152 then + return -1 +endi +sql_error select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb2.ts desc) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; +sql select count(a.col1) from (select tb1.ts,tb1.col1 from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts session(a.ts, 1s);; + +#left join + inner join +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts and tb1.t1=tb2.t1) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tba1.ts from tba1 join tba2 on tba1.ts=tba2.ts) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) b on a.ts = b.ts; + +#left join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left join + left semi join +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left join (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left join + left anti join +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left join (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left join + left asof join +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2 order by tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left join (select tb1.ts from sta tb1 left asof join sta tb2 order by tb1.ts desc) b on a.ts = b.ts; + +#left join + left window join +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb2.ts) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a left join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a left join (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb1.ts desc) b on a.ts = b.ts; +#left semi join + inner join +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts and tb1.t1=tb2.t1) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tba1.ts from tba1 join tba2 on tba1.ts=tba2.ts) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left semi join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left semi join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left semi join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left semi join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left semi join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) b on a.ts = b.ts; +#left semi join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left semi join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left semi join + left semi join +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left semi join (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left semi join + left anti join +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left semi join (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left semi join + left asof join +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2 order by tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left semi join (select tb1.ts from sta tb1 left asof join sta tb2 order by tb1.ts desc) b on a.ts = b.ts; + +#left semi join + left window join +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb2.ts) a left semi join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a left semi join sta b on a.ts = b.ts; + + +#left anti join + inner join +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts and tb1.t1=tb2.t1) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tba1.ts from tba1 join tba2 on tba1.ts=tba2.ts) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts) a left anti join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left anti join (select * from sta partition by tbname order by ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left anti join (select * from sta partition by tbname order by ts) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left anti join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts desc) a left anti join (select tb1.ts from sta tb1 join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) b on a.ts = b.ts; + +#left anti join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left anti join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left anti join + left semi join +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts) a left anti join (select tb1.ts from sta tb1 left semi join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left anti join + left anti join +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts) a left anti join (select tb1.ts from sta tb1 left anti join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b on a.ts = b.ts; + +#left anti join + left asof join +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2 order by tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left asof join sta tb2) a left anti join (select tb1.ts from sta tb1 left asof join sta tb2 order by tb1.ts desc) b on a.ts = b.ts; + +#left anti join + left window join +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s) order by tb2.ts) a left anti join sta b on a.ts = b.ts; +sql_error select a.ts from (select tb1.ts from sta tb1 left window join sta tb2 window_offset(-1s,1s)) a left anti join sta b on a.ts = b.ts; + +#left asof join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left asof join sta b; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left asof join sta b; +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left asof join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b; + +#left window join + left join +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb2.ts) a left window join sta b window_offset(-1s, 1s); +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left window join sta b window_offset(-1s, 1s); +sql_error select a.ts from (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts) a left window join (select tb1.ts from sta tb1 left join sta tb2 on tb1.ts=tb2.ts order by tb1.ts desc) b window_offset(-1s, 1s); + + +#multi level join +sql select a.ts from sta a join sta b on a.ts = b.ts join sta c on b.ts = c.ts; +if $rows != 20 then + return -1 +endi +sql_error select a.ts from sta a join sta b on a.ts = b.ts left join sta c on b.ts = c.ts; +sql_error select a.ts from sta a join sta b on a.ts = b.ts left semi join sta c on b.ts = c.ts; +sql select a.ts from sta a left join sta b on a.ts = b.ts join sta c on b.ts = c.ts; +sql select a.ts from sta a left semi join sta b on a.ts = b.ts join sta c on b.ts = c.ts; +sql select a.ts from sta a left anti join sta b on a.ts = b.ts join sta c on b.ts = c.ts; +sql select a.ts from (sta a left asof join sta b) join sta c on b.ts = c.ts; +sql select a.ts from sta a left window join sta b window_offset(-1s,1s) join sta c on b.ts = c.ts; +sql_error select a.ts from sta a left join sta b on a.ts = b.ts left join sta c on b.ts = c.ts; +sql_error select a.ts from sta a left semi join sta b on a.ts = b.ts left join sta c on b.ts = c.ts; +sql_error select a.ts from sta a left anti join sta b on a.ts = b.ts left semi join sta c on b.ts = c.ts; +sql select a.ts from sta a full join sta b on a.ts = b.ts join sta c on b.ts = c.ts; + + +#timeline + inner join sql select sum(c1) from (select a.col1 c1 from sta a join sta b on a.ts = b.ts and a.t1 = b.t1); if $rows != 1 then return -1 @@ -35,6 +364,30 @@ endi if $data00 != 3 then return -1 endi +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts where b.t1 > 1); +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts where b.t1 > 1); +if $rows != 0 then + return -1 +endi +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts where b.t1 > 1); +if $rows != 0 then + return -1 +endi +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left asof join sta b); +if $rows != 3 then + return -1 +endi +sql select diff(c1) from (select distinct a.ts, a.col1 c1 from tba1 a left window join sta b window_offset(-1s, 0s) order by a.ts); +if $rows != 3 then + return -1 +endi + sql select diff(c1) from (select b.col1 c1, a.ts from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 where a.t1 > 1 order by a.ts); if $rows != 3 then @@ -108,3 +461,476 @@ sql_error select diff(c1) from (select a.col1 c1, a.ts from sta a join sta b on sql_error select count(c1) from (select a.col1 c1 from tba1 a join sta b on a.ts = b.ts) interval(1s); sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a join sta b on a.ts = b.ts partition by a.col1) c session(c.ts, 1s); +#timeline + left join +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left join tba2 b on a.ts = b.ts); +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi + +sql_error select diff(c1) from (select b.col1 c1 from tba1 a left join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select b.ts, b.col1 c1 from tba1 a left join tba2 b on a.ts = b.ts); +sql select diff(c1) from (select a.ts, b.col1 c1 from tba1 a left join tba2 b on a.ts = b.ts); +if $rows != 3 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != NULL then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1 from tba1 a left join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts order by b.ts) interval(1s); +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts) interval(1s); +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts) c session(c.ts1, 1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts order by ts1) c session(c.ts1, 1s); +sql select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 4 then + return -1 +endi + + +#timeline + left semi join +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left semi join tba2 b on a.ts = b.ts); +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi + +sql_error select diff(c1) from (select b.col1 c1 from tba1 a left semi join tba2 b on a.ts = b.ts); +sql select diff(c1) from (select b.ts, b.col1 c1 from tba1 a left semi join tba2 b on a.ts = b.ts); +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi + +sql select diff(c1) from (select a.ts, b.col1 c1 from tba1 a left semi join tba2 b on a.ts = b.ts); +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts) interval(1s); +sql select count(c1) from (select b.ts, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts) interval(1s); +if $rows != 4 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 + +sql select count(c1) from (select b.ts, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts order by b.ts) interval(1s); +if $rows != 4 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 +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts) interval(1s); +if $rows != 4 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 + +sql select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts order by ts1) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left semi join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +#timeline + left anti join +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left anti join tba2 b on a.ts = b.ts); +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi + +sql_error select diff(c1) from (select b.col1 c1 from tba1 a left anti join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select b.ts, b.col1 c1 from tba1 a left anti join tba2 b on a.ts = b.ts); + +#???? +sql select diff(c1) from (select b.ts, b.col1 c1,a.ts from tba1 a left anti join tba2 b on a.ts = b.ts); +sql select diff(c1) from (select a.ts, b.col1 c1 from tba1 a left anti join tba2 b on a.ts = b.ts); + +sql_error select count(c1) from (select a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts order by b.ts) interval(1s); +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts) interval(1s); +if $rows != 0 then + return -1 +endi +sql select count(c1) from (select a.col1 c1,a.ts from tba1 a left anti join sta b on a.ts = b.ts) interval(1s); +if $rows != 0 then + return -1 +endi + +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts) c session(c.ts1, 1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts order by ts1) c session(c.ts1, 1s); +sql select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left anti join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 0 then + return -1 +endi +sql select count(c1) from (select a.col1 c1, timetruncate(a.ts, 1d) ts1 from tba1 a left anti join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 0 then + return -1 +endi +sql select count(c1) from (select a.col1 c1, a.ts + 1s ts1 from tba1 a left anti join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 0 then + return -1 +endi + + +#timeline + left asof join +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left asof join tba2 b); +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +sql_error select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left asof join tba2 b on a.col1 = b.col1); +sql_error select diff(c1) from (select b.col1 c1 from tba1 a left asof join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select b.ts, b.col1 c1 from tba1 a left asof join tba2 b on a.ts = b.ts); + +sql select diff(c1) from (select b.ts, b.col1 c1,a.ts from tba1 a left asof join tba2 b on a.ts = b.ts); +if $rows != 3 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != NULL then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts order by b.ts) interval(1s); +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left asof join sta b on a.col1 = b.col1) interval(1s); +if $rows != 4 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 +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts) interval(1s); +if $rows != 4 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 +sql select count(c1) from (select a.col1 c1,a.ts from tba1 a left asof join sta b on a.ts = b.ts) interval(1s); +if $rows != 4 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 + +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts) c session(c.ts1, 1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts order by ts1) c session(c.ts1, 1s); +sql_error select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left asof join sta b on a.col1 = b.col1) c session(c.ts1, 1s); +sql select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left asof join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1, timetruncate(a.ts, 1d) ts1 from tba1 a left asof join sta b on a.col1 = b.col1) c session(c.ts1, 1s); +sql select count(c1) from (select a.col1 c1, timetruncate(a.ts, 1d) ts1 from tba1 a left asof join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 1 then + return -1 +endi +if $data00 != 4 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1, a.ts + 1s ts1 from tba1 a left asof join sta b on a.col1 = b.col1) c session(c.ts1, 1s); +sql select count(c1) from (select a.col1 c1, a.ts + 1s ts1 from tba1 a left asof join sta b on a.ts = b.ts) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +#timeline + left window join +sql select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left window join tba2 b window_offset(1s,1s)); +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +sql_error select diff(c1) from (select a.ts, a.col1 c1 from tba1 a left window join tba2 b on a.col1 = b.col1 window_offset(1s,1s)); +sql_error select diff(c1) from (select b.col1 c1 from tba1 a left window join tba2 b window_offset(1s,1s)); +sql_error select diff(c1) from (select b.ts, b.col1 c1 from tba1 a left window join tba2 b window_offset(1s,1s)); + +sql select diff(c1) from (select b.ts, b.col1 c1,a.ts from tba1 a left window join tba2 b window_offset(1s,1s)); +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s)) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s)) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s) order by b.ts) interval(1s); +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left window join sta b on a.col1 = b.col1 window_offset(-1s,1s)) interval(1s); +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +sql select count(c1) from (select a.ts, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s)) interval(1s); +if $rows != 4 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 4 then + return -1 +endi +sql select count(c1) from (select a.col1 c1,a.ts from tba1 a left window join sta b window_offset(-1s,1s)) interval(1s); +if $rows != 4 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 4 then + return -1 +endi + +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s)) c session(c.ts1, 1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s) order by ts1) c session(c.ts1, 1s); +sql_error select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left window join sta b on a.col1 = b.col1 window_offset(-1s,1s)) c session(c.ts1, 1s); +sql select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a left window join sta b window_offset(-1s,1s)) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +if $data10 != 12 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1, timetruncate(a.ts, 1d) ts1 from tba1 a left window join sta b on a.col1 = b.col1 window_offset(-1s,1s)) c session(c.ts1, 1s); +sql select count(c1) from (select a.col1 c1, timetruncate(a.ts, 1d) ts1 from tba1 a left window join sta b window_offset(-1s,1s)) c session(c.ts1, 1s); +if $rows != 1 then + return -1 +endi +if $data00 != 15 then + return -1 +endi + +sql_error select count(c1) from (select a.col1 c1, a.ts + 1s ts1 from tba1 a left window join sta b on a.col1 = b.col1 window_offset(-1s,1s)) c session(c.ts1, 1s); +sql select count(c1) from (select a.col1 c1, a.ts + 1s ts1 from tba1 a left window join sta b window_offset(-1s,1s)) c session(c.ts1, 1s); +if $rows != 2 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +if $data10 != 12 then + return -1 +endi + +#timeline + full join +sql_error select diff(c1) from (select a.ts, a.col1 c1 from tba1 a full join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select b.col1 c1 from tba1 a full join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select b.ts, b.col1 c1 from tba1 a full join tba2 b on a.ts = b.ts); +sql_error select diff(c1) from (select a.ts, b.col1 c1 from tba1 a full join tba2 b on a.ts = b.ts); +sql_error select count(c1) from (select a.col1 c1 from tba1 a full join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts order by b.ts) interval(1s); +sql_error select count(c1) from (select a.ts, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts) interval(1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts) c session(c.ts1, 1s); +sql_error select count(c1) from (select b.ts ts1, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts order by ts1) c session(c.ts1, 1s); +sql_error select count(c1) from (select a.ts ts1, a.col1 c1 from tba1 a full join sta b on a.ts = b.ts) c session(c.ts1, 1s); + + + +