diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 5f985fe493..3f3ec065a6 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -768,6 +768,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_WIN_OFFSET_UNIT TAOS_DEF_ERROR_CODE(0, 0x2673) #define TSDB_CODE_PAR_VALID_PRIM_TS_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x2674) #define TSDB_CODE_PAR_ORDERBY_UNKNOWN_EXPR TAOS_DEF_ERROR_CODE(0, 0x2675) +#define TSDB_CODE_PAR_NOT_WIN_FUNC TAOS_DEF_ERROR_CODE(0, 0x2676) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 2537931f05..80c56d690d 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -401,6 +401,14 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); } } + + if (pTagScanNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pTagScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, + TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } } break; } diff --git a/source/libs/executor/inc/mergejoin.h b/source/libs/executor/inc/mergejoin.h index 2685e6952a..a51c9444ce 100755 --- a/source/libs/executor/inc/mergejoin.h +++ b/source/libs/executor/inc/mergejoin.h @@ -306,6 +306,7 @@ typedef struct SMJoinOperatorInfo { int32_t inputTsOrder; int32_t errCode; int64_t outGrpId; + uint64_t outBlkId; SMJoinTableCtx tbs[2]; SMJoinTableCtx* build; SMJoinTableCtx* probe; diff --git a/source/libs/executor/src/mergejoinoperator.c b/source/libs/executor/src/mergejoinoperator.c index 9c11a5c5ae..e13b0f63d5 100644 --- a/source/libs/executor/src/mergejoinoperator.c +++ b/source/libs/executor/src/mergejoinoperator.c @@ -1047,6 +1047,7 @@ static FORCE_INLINE SSDataBlock* mJoinRetrieveImpl(SMJoinOperatorInfo* pJoin, SM static int32_t mJoinInitCtx(SMJoinOperatorInfo* pJoin, SSortMergeJoinPhysiNode* pJoinNode) { pJoin->ctx.mergeCtx.groupJoin = pJoinNode->grpJoin; pJoin->retrieveFp = pJoinNode->grpJoin ? mJoinGrpRetrieveImpl : mJoinRetrieveImpl; + pJoin->outBlkId = pJoinNode->node.pOutputDataBlockDesc->dataBlockId; if ((JOIN_STYPE_ASOF == pJoin->subType && (ASOF_LOWER_ROW_INCLUDED(pJoinNode->asofOpType) || ASOF_GREATER_ROW_INCLUDED(pJoinNode->asofOpType))) || (JOIN_STYPE_WIN == pJoin->subType)) { @@ -1552,6 +1553,8 @@ SSDataBlock* mJoinMainProcess(struct SOperatorInfo* pOperator) { } break; } + + pBlock->info.id.blockId = pJoin->outBlkId; if (pJoin->pFinFilter != NULL) { doFilter(pBlock, pJoin->pFinFilter, NULL); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 21a18cbe4e..9dd9b44685 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1910,12 +1910,19 @@ static int32_t rewriteCountStarAsCount1(STranslateContext* pCxt, SFunctionNode* static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) { SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pCount->pParameterList, 0); STableNode* pTable = NULL; - int32_t code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); - if (TSDB_CODE_SUCCESS == code) { - if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { - setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, -1, pCol); - } else { - code = rewriteCountStarAsCount1(pCxt, pCount); + SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); + size_t nums = taosArrayGetSize(pTables); + int32_t code = 0; + if ('\0' == pCol->tableAlias[0] && nums > 1) { + code = rewriteCountStarAsCount1(pCxt, pCount); + } else { + code = findTable(pCxt, ('\0' == pCol->tableAlias[0] ? NULL : pCol->tableAlias), &pTable); + if (TSDB_CODE_SUCCESS == code) { + if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { + setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, -1, pCol); + } else { + code = rewriteCountStarAsCount1(pCxt, pCount); + } } } return code; @@ -2884,6 +2891,33 @@ static bool isWindowJoinProbeTablePrimCol(SSelectStmt* pSelect, SNode* p return false; } +static bool isWindowJoinProbeTableCol(SSelectStmt* pSelect, SNode* pNode) { + if (QUERY_NODE_COLUMN != nodeType(pNode)) { + return false; + } + + SColumnNode* pCol = (SColumnNode*)pNode; + SJoinTableNode* pJoinTable = (SJoinTableNode*)pSelect->pFromTable; + SRealTableNode* pProbeTable = NULL; + switch (pJoinTable->joinType) { + case JOIN_TYPE_LEFT: + pProbeTable = (SRealTableNode*)pJoinTable->pLeft; + break; + case JOIN_TYPE_RIGHT: + pProbeTable = (SRealTableNode*)pJoinTable->pRight; + break; + default: + return false; + } + + if (0 == strcmp(pCol->dbName, pProbeTable->table.dbName) && 0 == strcmp(pCol->tableAlias, pProbeTable->table.tableAlias)) { + return true; + } + + return false; +} + + typedef struct SCheckColContaisCtx { SNode* pTarget; bool contains; @@ -2916,6 +2950,85 @@ static bool isWindowJoinGroupCol(SSelectStmt* pSelect, SNode* pNode) { return ctx.contains; } +static bool isWindowJoinSubTbTag(SSelectStmt* pSelect, SNode* pNode) { + if (QUERY_NODE_COLUMN != nodeType(pNode)) { + return false; + } + SColumnNode* pCol = (SColumnNode*)pNode; + if (COLUMN_TYPE_TAG != pCol->colType) { + return false; + } + + SJoinTableNode* pJoinTable = (SJoinTableNode*)pSelect->pFromTable; + SRealTableNode* pProbeTable = NULL; + SRealTableNode* pBuildTable = NULL; + switch (pJoinTable->joinType) { + case JOIN_TYPE_LEFT: + pProbeTable = (SRealTableNode*)pJoinTable->pLeft; + pBuildTable = (SRealTableNode*)pJoinTable->pRight; + break; + case JOIN_TYPE_RIGHT: + pProbeTable = (SRealTableNode*)pJoinTable->pRight; + pBuildTable = (SRealTableNode*)pJoinTable->pLeft; + break; + default: + return false; + } + + SRealTableNode* pTargetTable = pProbeTable; + if (0 != strcasecmp(pCol->tableAlias, pProbeTable->table.tableAlias)) { + pTargetTable = pBuildTable; + } + + if (TSDB_CHILD_TABLE != pTargetTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTargetTable->pMeta->tableType) { + return false; + } + + return true; +} + + +static bool isWindowJoinSubTbname(SSelectStmt* pSelect, SNode* pNode) { + if (QUERY_NODE_FUNCTION != nodeType(pNode)) { + return false; + } + + SFunctionNode* pFuncNode = (SFunctionNode*)pNode; + if (FUNCTION_TYPE_TBNAME != pFuncNode->funcType) { + return false; + } + + SJoinTableNode* pJoinTable = (SJoinTableNode*)pSelect->pFromTable; + SRealTableNode* pProbeTable = NULL; + SRealTableNode* pBuildTable = NULL; + switch (pJoinTable->joinType) { + case JOIN_TYPE_LEFT: + pProbeTable = (SRealTableNode*)pJoinTable->pLeft; + pBuildTable = (SRealTableNode*)pJoinTable->pRight; + break; + case JOIN_TYPE_RIGHT: + pProbeTable = (SRealTableNode*)pJoinTable->pRight; + pBuildTable = (SRealTableNode*)pJoinTable->pLeft; + break; + default: + return false; + } + + SRealTableNode* pTargetTable = pProbeTable; + bool isProbeTable = true; + SValueNode* pVal = (SValueNode*)nodesListGetNode(pFuncNode->pParameterList, 0); + if (NULL != pVal && 0 != strcasecmp(pVal->literal, pProbeTable->table.tableAlias)) { + pTargetTable = pBuildTable; + isProbeTable = false; + } + + if (!isProbeTable && TSDB_CHILD_TABLE != pTargetTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTargetTable->pMeta->tableType) { + return false; + } + + return true; +} + static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { STranslateContext* pCxt = (STranslateContext*)pContext; SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; @@ -2943,18 +3056,20 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { return rewriteExprToGroupKeyFunc(pCxt, pNode); } } - if (isWindowJoinStmt(pSelect)) { - if (isWindowJoinProbeTablePrimCol(pSelect, *pNode) || isWindowJoinGroupCol(pSelect, *pNode)) { + + if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { + if (pSelect->selectFuncNum > 1 || (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) { + return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias); + } + if (isWindowJoinStmt(pSelect) && (isWindowJoinProbeTableCol(pSelect, *pNode) || isWindowJoinGroupCol(pSelect, *pNode) || (isWindowJoinSubTbname(pSelect, *pNode)) || isWindowJoinSubTbTag(pSelect, *pNode))) { return rewriteExprToGroupKeyFunc(pCxt, pNode); } - } - if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { - if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc || - (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) { + + if (pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc){ return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias); - } else { - return rewriteColToSelectValFunc(pCxt, pNode); } + + return rewriteColToSelectValFunc(pCxt, pNode); } if (isVectorFunc(*pNode) && isDistinctOrderBy(pCxt)) { return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias); @@ -2996,6 +3111,7 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt* typedef struct CheckAggColCoexistCxt { STranslateContext* pTranslateCxt; bool existCol; + SNodeList* pColList; } CheckAggColCoexistCxt; static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) { @@ -3015,6 +3131,19 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } +static EDealRes doCheckGetAggColCoexist(SNode** pNode, void* pContext) { + CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext; + if (isVectorFunc(*pNode)) { + return DEAL_RES_IGNORE_CHILD; + } + if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { + pCxt->existCol = true; + nodesListMakeStrictAppend(&pCxt->pColList, *pNode); + } + return DEAL_RES_CONTINUE; +} + + static int32_t checkIsEmptyResult(STranslateContext* pCxt, SSelectStmt* pSelect) { if (pSelect->timeRange.skey > pSelect->timeRange.ekey && !pSelect->hasCountFunc) { @@ -3063,6 +3192,42 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) return TSDB_CODE_SUCCESS; } +static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (!isWindowJoinStmt(pSelect) || (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc)) { + return TSDB_CODE_SUCCESS; + } + if (!pSelect->onlyHasKeepOrderFunc) { + pSelect->timeLineResMode = TIME_LINE_NONE; + } + CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt, .existCol = false, .pColList = NULL}; + nodesRewriteExprs(pSelect->pProjectionList, doCheckGetAggColCoexist, &cxt); + if (!pSelect->isDistinct) { + nodesRewriteExprs(pSelect->pOrderByList, doCheckGetAggColCoexist, &cxt); + } + if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum) ) + && !pSelect->hasOtherVectorFunc) { + return rewriteColsToSelectValFunc(pCxt, pSelect); + } + + if (cxt.existCol) { + bool allProbeTableCols = true; + SNode* pNode = NULL; + FOREACH(pNode, cxt.pColList) { + if (isWindowJoinProbeTableCol(pSelect, pNode) || isWindowJoinGroupCol(pSelect, pNode) || (isWindowJoinSubTbname(pSelect, pNode)) || isWindowJoinSubTbTag(pSelect, pNode)) { + continue; + } + + allProbeTableCols = false; + break; + } + + if (!allProbeTableCols) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_WIN_FUNC); + } + } + return TSDB_CODE_SUCCESS; +} + static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) { int32_t code = TSDB_CODE_SUCCESS; if (NULL == getGroupByList(pCxt) && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow && !isWindowJoinStmt(pSelect)) { @@ -5577,6 +5742,11 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect resetSelectFuncNumWithoutDup(pSelect); code = checkAggColCoexist(pCxt, pSelect); } +/* + if (TSDB_CODE_SUCCESS == code) { + code = checkWinJoinAggColCoexist(pCxt, pSelect); + } +*/ if (TSDB_CODE_SUCCESS == code) { code = checkWindowGrpFuncCoexist(pCxt, pSelect); } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index ec17c3f27b..a923b62f86 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -200,6 +200,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid WINDOW_OFFSET unit \"%c\""; case TSDB_CODE_PAR_VALID_PRIM_TS_REQUIRED: return "Valid primary timestamp required"; + case TSDB_CODE_PAR_NOT_WIN_FUNC: + return "Column exists for window join with aggregation functions"; default: return "Unknown error"; } diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index b293b27528..fd1c40db77 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -100,7 +100,7 @@ static SJoinOptimizeOpt gJoinWhereOpt[JOIN_TYPE_MAX_VALUE][JOIN_STYPE_MAX_VALUE] /* NONE OUTER SEMI ANTI ASOF WINDOW */ /*INNER*/ {{PUSH_DOWN_ALL_COND}, {0}, {0}, {0}, {0}, {0}}, /*LEFT*/ {{0}, {PUSH_DOWN_LEFT_FLT}, {PUSH_DOWN_LEFT_FLT}, {PUSH_DOWN_LEFT_FLT}, {PUSH_DOWN_LEFT_FLT}, {PUSH_DOWN_LEFT_FLT}}, -/*RIGHT*/ {{0}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}}, +/*RIGHT*/ {{0}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT},{PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}}, /*FULL*/ {{0}, {0}, {0}, {0}, {0}, {0}}, }; @@ -108,7 +108,7 @@ static SJoinOptimizeOpt gJoinOnOpt[JOIN_TYPE_MAX_VALUE][JOIN_STYPE_MAX_VALUE] = /* NONE OUTER SEMI ANTI ASOF WINDOW */ /*INNER*/ {{PUSH_DONW_FLT_COND}, {0}, {0}, {0}, {0}, {0}}, /*LEFT*/ {{0}, {0}, {PUSH_DONW_FLT_COND}, {0}, {0}, {0}}, -/*RIGHT*/ {{0}, {0}, {PUSH_DONW_FLT_COND}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}, {PUSH_DOWN_RIGHT_FLT}}, +/*RIGHT*/ {{0}, {0}, {PUSH_DONW_FLT_COND}, {0}, {0}, {0}}, /*FULL*/ {{0}, {0}, {0}, {0}, {0}, {0}}, }; @@ -925,8 +925,8 @@ static bool pdcJoinIsEqualOnCond(SJoinLogicNode* pJoin, SNode* pCond, bool* allT } else if (pdcJoinColInTableColList((SNode*)pLeft, pRightCols)) { isEqual = pdcJoinColInTableColList((SNode*)pRight, pLeftCols); if (isEqual) { - nodesListMakeStrictAppend(&pJoin->pLeftEqNodes, nodesCloneNode(pOper->pLeft)); - nodesListMakeStrictAppend(&pJoin->pRightEqNodes, nodesCloneNode(pOper->pRight)); + nodesListMakeStrictAppend(&pJoin->pLeftEqNodes, nodesCloneNode(pOper->pRight)); + nodesListMakeStrictAppend(&pJoin->pRightEqNodes, nodesCloneNode(pOper->pLeft)); } } @@ -1180,8 +1180,8 @@ static int32_t pdcJoinAddPreFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogi return code; } -static int32_t pdcJoinAddWhereFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { - if (NULL == pJoin->node.pConditions && (!IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) || NULL == pJoin->pFullOnCond)) { +static int32_t pdcJoinAddFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { + if (NULL == pJoin->node.pConditions && NULL == pJoin->pFullOnCond) { return TSDB_CODE_SUCCESS; } @@ -1195,7 +1195,7 @@ static int32_t pdcJoinAddWhereFilterColsToTarget(SOptimizeContext* pCxt, SJoinLo if (NULL != pJoin->node.pConditions) { code = nodesCollectColumnsFromNode(pJoin->node.pConditions, NULL, COLLECT_COL_TYPE_ALL, &pCondCols); } - if (TSDB_CODE_SUCCESS == code && IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond) { + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pFullOnCond) { code = nodesCollectColumnsFromNode(pJoin->pFullOnCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols); } if (TSDB_CODE_SUCCESS == code) { @@ -1245,7 +1245,7 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin SNode* pCond = pJoin->pFullOnCond ? pJoin->pFullOnCond : pJoin->node.pConditions; bool errCond = false; if (!pdcJoinHasPrimEqualCond(pJoin, pCond, &errCond)) { - if (errCond) { + if (errCond && !(IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && NULL != pJoin->node.pConditions)) { return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_NOT_SUPPORT_JOIN_COND); } @@ -1366,12 +1366,12 @@ static int32_t pdcDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { code = pdcJoinAddParentOnColsToTarget(pCxt, pJoin); } - if (TSDB_CODE_SUCCESS == code) { - code = pdcJoinAddPreFilterColsToTarget(pCxt, pJoin); - } + //if (TSDB_CODE_SUCCESS == code) { + // code = pdcJoinAddPreFilterColsToTarget(pCxt, pJoin); + //} if (TSDB_CODE_SUCCESS == code) { - code = pdcJoinAddWhereFilterColsToTarget(pCxt, pJoin); + code = pdcJoinAddFilterColsToTarget(pCxt, pJoin); } if (TSDB_CODE_SUCCESS == code) { @@ -4468,6 +4468,9 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL // break; //} + nodesDestroyNode(pScan->pTagCond); + nodesDestroyNode(pScan->pTagIndexCond); + pScan->node.dynamicOp = true; *(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 8b85ae7082..8decf3d480 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -768,9 +768,9 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI } if (leftBlkId == ((SColumnNode*)pOp->pRight)->dataBlockId) { - nodesListMakeStrictAppend(ppLeft, nodesCloneNode(pOp->pLeft)); + nodesListMakeStrictAppend(ppLeft, nodesCloneNode(pOp->pRight)); } else if (rightBlkId == ((SColumnNode*)pOp->pRight)->dataBlockId) { - nodesListMakeStrictAppend(ppRight, nodesCloneNode(pOp->pLeft)); + nodesListMakeStrictAppend(ppRight, nodesCloneNode(pOp->pRight)); } else { planError("invalid col equal list, rightBlockId:%d", ((SColumnNode*)pOp->pRight)->dataBlockId); return TSDB_CODE_PLAN_INTERNAL_ERROR; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 31f19a7492..dcada5302f 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -632,6 +632,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GRP_WINDOW_NOT_ALLOWED, "GROUP BY/PARTITION TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_WIN_OFFSET_UNIT, "Invalid window offset unit") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VALID_PRIM_TS_REQUIRED, "Valid primary timestamp required") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ORDERBY_UNKNOWN_EXPR, "Invalid expr in order by clause") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_WIN_FUNC, "Column exists for window join with aggregation functions") //planner TAOS_DEFINE_ERROR(TSDB_CODE_PLAN_INTERNAL_ERROR, "Planner internal error") diff --git a/tests/script/tsim/join/join.sim b/tests/script/tsim/join/join.sim index d281c96464..e3a04fc9c1 100644 --- a/tests/script/tsim/join/join.sim +++ b/tests/script/tsim/join/join.sim @@ -85,7 +85,8 @@ run tsim/join/left_asof_join.sim run tsim/join/right_asof_join.sim run tsim/join/left_win_join.sim run tsim/join/right_win_join.sim -run tsim/join/join_scalar.sim +run tsim/join/join_scalar1.sim +run tsim/join/join_scalar2.sim run tsim/join/join_timeline.sim run tsim/join/join_nested.sim run tsim/join/join_boundary.sim @@ -109,7 +110,8 @@ run tsim/join/left_asof_join.sim run tsim/join/right_asof_join.sim run tsim/join/left_win_join.sim run tsim/join/right_win_join.sim -run tsim/join/join_scalar.sim +run tsim/join/join_scalar1.sim +run tsim/join/join_scalar2.sim run tsim/join/join_timeline.sim run tsim/join/join_nested.sim run tsim/join/join_boundary.sim diff --git a/tests/script/tsim/join/join_scalar.sim b/tests/script/tsim/join/join_scalar.sim deleted file mode 100644 index d8fb9c663e..0000000000 --- a/tests/script/tsim/join/join_scalar.sim +++ /dev/null @@ -1,240 +0,0 @@ -sql connect -sql use test0; - -sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); -if $rows != 64 then - return -1 -endi - -sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); -if $rows != 64 then - return -1 -endi - -sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) and a.col1=b.col1; -if $rows != 12 then - return -1 -endi - -sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1m) = b.ts; -if $rows != 16 then - return -1 -endi - -sql select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) = a.ts; -if $rows != 8 then - return -1 -endi - -sql select a.ts, b.col1,timetruncate(a.col1, 1h) from sta a left join sta b on a.ts = b.ts and timetruncate(a.col1, 1h) = timetruncate(a.col1, 1h); -if $rows != 12 then - return -1 -endi - -sql select a.ts, b.col1 from sta a left semi join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); -if $rows != 8 then - return -1 -endi - -sql select a.ts, b.col1 from sta a left anti join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); -if $rows != 0 then - return -1 -endi - -sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h); -if $rows != 8 then - return -1 -endi -sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2; -if $rows != 16 then - return -1 -endi -sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 8; -if $rows != 64 then - return -1 -endi -sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 9; -if $rows != 64 then - return -1 -endi - -sql select a.ts, b.ts from sta a left asof join sta b on a.col1 =b.col1 and timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h) jlimit 2; -if $rows != 8 then - return -1 -endi - -sql select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2 where timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h); -if $rows != 16 then - return -1 -endi - -sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts=b.ts and a.ts=b.ts; -sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h) and timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h); -sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) and a.ts > timetruncate(b.ts, 1s) jlimit 2; -sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts > timetruncate(b.ts, 1s) and timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2; -sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) and a.ts =b.col1 jlimit 2; -sql_error select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) + 1 = a.ts; -sql_error select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) = a.ts + 1; -sql_error select a.ts, b.col1 from sta a left join sta b on b.ts + 1 = a.ts + 1; - -sql use testa; - -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1a) = timetruncate(sta2.ts, 1a); -if $rows != 8 then - return -1 -endi -if $data00 != @23-10-16 09:10:11.001@ then - return -1 -endi -if $data01 != NULL then - return -1 -endi -if $data10 != NULL then - return -1 -endi -if $data11 != @23-10-16 09:10:11.002@ then - return -1 -endi - -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1a) = timetruncate(sta2.ts, 1a) and sta1.ts=sta2.ts; -if $rows != 8 then - return -1 -endi - -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1s) = timetruncate(sta2.ts, 1s); -if $rows != 4 then - return -1 -endi -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1m) = timetruncate(sta2.ts, 1m); -if $rows != 16 then - return -1 -endi -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 16 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data01 != @23-10-16 09:10:11.002@ then - return -1 -endi - -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 16 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data01 != @23-10-16 09:10:11.002@ then - return -1 -endi -sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1d) = timetruncate(sta2.ts, 1d, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 8 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data01 != NULL then - return -1 -endi -sql select sta1.ts,timetruncate(sta1.ts, 1d), sta2.ts, timetruncate(sta2.ts, 1d, 0) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1d) >= timetruncate(sta2.ts, 1d, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 4 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data02 != NULL then - return -1 -endi -if $data10 != @23-10-16 09:10:13.001@ then - return -1 -endi -if $data12 != NULL then - return -1 -endi -sql select sta1.ts,timetruncate(sta1.ts, 1d, 0), sta2.ts, timetruncate(sta2.ts, 1d, 1) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1d, 0) >= timetruncate(sta2.ts, 1d, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 16 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data02 != @23-10-16 09:10:11.002@ then - return -1 -endi -if $data10 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data12 != @23-10-16 09:10:12.002@ then - return -1 -endi -sql select sta1.ts, sta2.ts from sta1 left asof join sta2 on timetruncate(sta1.ts, 1s, 0) > timetruncate(sta2.ts, 1s, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 7 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data01 != @23-10-16 09:10:11.002@ then - return -1 -endi -if $data10 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data11 != @23-10-16 09:10:12.002@ then - return -1 -endi -if $data20 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data21 != @23-10-16 09:10:13.002@ then - return -1 -endi -if $data30 != @23-10-16 09:10:13.001@ then - return -1 -endi -if $data31 != @23-10-16 09:10:11.002@ then - return -1 -endi -if $data40 != @23-10-16 09:10:13.001@ then - return -1 -endi -if $data41 != @23-10-16 09:10:12.002@ then - return -1 -endi -if $data50 != @23-10-16 09:10:12.001@ then - return -1 -endi -if $data51 != @23-10-16 09:10:11.002@ then - return -1 -endi -if $data60 != @23-10-16 09:10:11.001@ then - return -1 -endi -if $data61 != NULL then - return -1 -endi - -sql select sta1.ts,timetruncate(sta1.ts, 1w, 0), sta2.ts,timetruncate(sta2.ts, 1w, 1) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1w, 0) > timetruncate(sta2.ts, 1w, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); -if $rows != 16 then - return -1 -endi -if $data00 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data02 != @23-10-16 09:10:11.002@ then - return -1 -endi -if $data10 != @23-10-16 09:10:14.001@ then - return -1 -endi -if $data12 != @23-10-16 09:10:12.002@ then - return -1 -endi - - -sql_error select count(*) from sta1 left window join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h) window_offset(-1s, 1s); diff --git a/tests/script/tsim/join/join_scalar1.sim b/tests/script/tsim/join/join_scalar1.sim new file mode 100644 index 0000000000..dc355ddc88 --- /dev/null +++ b/tests/script/tsim/join/join_scalar1.sim @@ -0,0 +1,1215 @@ +sql connect +sql use test0; + +# timetruncate +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); +if $rows != 64 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); +if $rows != 64 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) and a.col1=b.col1; +if $rows != 12 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1m) = b.ts; +if $rows != 16 then + return -1 +endi + +sql select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) = a.ts; +if $rows != 8 then + return -1 +endi + +sql select a.ts, b.col1,timetruncate(a.col1, 1h) from sta a left join sta b on a.ts = b.ts and timetruncate(a.col1, 1h) = timetruncate(a.col1, 1h); +if $rows != 12 then + return -1 +endi + +sql select a.ts, b.col1 from sta a left semi join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi + +sql select a.ts, b.col1 from sta a left anti join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h); +if $rows != 0 then + return -1 +endi + +sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2; +if $rows != 16 then + return -1 +endi +sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 8; +if $rows != 64 then + return -1 +endi +sql select a.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 9; +if $rows != 64 then + return -1 +endi + +sql select a.ts, b.ts from sta a left asof join sta b on a.col1 =b.col1 and timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h) jlimit 2; +if $rows != 8 then + return -1 +endi + +sql select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2 where timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h); +if $rows != 16 then + return -1 +endi + +sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts=b.ts and a.ts=b.ts; +sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h) and timetruncate(a.ts, 1h) > timetruncate(b.ts, 1h); +sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) and a.ts > timetruncate(b.ts, 1s) jlimit 2; +sql_error select a.ts, b.ts from sta a left asof join sta b on a.ts > timetruncate(b.ts, 1s) and timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) jlimit 2; +sql_error select a.ts, b.ts from sta a left asof join sta b on timetruncate(a.ts, 1h) >= timetruncate(b.ts, 1h) and a.ts =b.col1 jlimit 2; +sql_error select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) + 1 = a.ts; +sql_error select a.ts, b.col1 from sta a left join sta b on timetruncate(b.ts, 1h) = a.ts + 1; +sql_error select a.ts, b.col1 from sta a left join sta b on b.ts + 1 = a.ts + 1; + +sql use testa; + +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1a) = timetruncate(sta2.ts, 1a); +if $rows != 8 then + return -1 +endi +if $data00 != @23-10-16 09:10:11.001@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != @23-10-16 09:10:11.002@ then + return -1 +endi + +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1a) = timetruncate(sta2.ts, 1a) and sta1.ts=sta2.ts; +if $rows != 8 then + return -1 +endi + +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1s) = timetruncate(sta2.ts, 1s); +if $rows != 4 then + return -1 +endi +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1m) = timetruncate(sta2.ts, 1m); +if $rows != 16 then + return -1 +endi +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 16 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data01 != @23-10-16 09:10:11.002@ then + return -1 +endi + +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 16 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data01 != @23-10-16 09:10:11.002@ then + return -1 +endi +sql select sta1.ts, sta2.ts from sta1 full join sta2 on timetruncate(sta1.ts, 1d) = timetruncate(sta2.ts, 1d, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 8 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql select sta1.ts,timetruncate(sta1.ts, 1d), sta2.ts, timetruncate(sta2.ts, 1d, 0) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1d) >= timetruncate(sta2.ts, 1d, 0) order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 4 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data10 != @23-10-16 09:10:13.001@ then + return -1 +endi +if $data12 != NULL then + return -1 +endi +sql select sta1.ts,timetruncate(sta1.ts, 1d, 0), sta2.ts, timetruncate(sta2.ts, 1d, 1) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1d, 0) >= timetruncate(sta2.ts, 1d, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 16 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data02 != @23-10-16 09:10:11.002@ then + return -1 +endi +if $data10 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data12 != @23-10-16 09:10:12.002@ then + return -1 +endi +sql select sta1.ts, sta2.ts from sta1 left asof join sta2 on timetruncate(sta1.ts, 1s, 0) > timetruncate(sta2.ts, 1s, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 7 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data01 != @23-10-16 09:10:11.002@ then + return -1 +endi +if $data10 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data11 != @23-10-16 09:10:12.002@ then + return -1 +endi +if $data20 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data21 != @23-10-16 09:10:13.002@ then + return -1 +endi +if $data30 != @23-10-16 09:10:13.001@ then + return -1 +endi +if $data31 != @23-10-16 09:10:11.002@ then + return -1 +endi +if $data40 != @23-10-16 09:10:13.001@ then + return -1 +endi +if $data41 != @23-10-16 09:10:12.002@ then + return -1 +endi +if $data50 != @23-10-16 09:10:12.001@ then + return -1 +endi +if $data51 != @23-10-16 09:10:11.002@ then + return -1 +endi +if $data60 != @23-10-16 09:10:11.001@ then + return -1 +endi +if $data61 != NULL then + return -1 +endi + +sql select sta1.ts,timetruncate(sta1.ts, 1w, 0), sta2.ts,timetruncate(sta2.ts, 1w, 1) from sta1 left asof join sta2 on timetruncate(sta1.ts, 1w, 0) > timetruncate(sta2.ts, 1w, 1) jlimit 4 order by timetruncate(sta1.ts, 1s) desc, timetruncate(sta2.ts, 1s); +if $rows != 16 then + return -1 +endi +if $data00 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data02 != @23-10-16 09:10:11.002@ then + return -1 +endi +if $data10 != @23-10-16 09:10:14.001@ then + return -1 +endi +if $data12 != @23-10-16 09:10:12.002@ then + return -1 +endi + +sql_error select count(*) from sta1 left window join sta2 on timetruncate(sta1.ts, 1h) = timetruncate(sta2.ts, 1h) window_offset(-1s, 1s); + + + +##### conditions +sql use test0; + +#inner join +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 64 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql select count(*),last(a.col1) from sta a join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 7 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +sql select first(b.col1),count(b.t1),last(a.col1) from sta a join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 7 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select a.tbname from sta a join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != tba2 then + return -1 +endi +sql_error select a.tbname from sta a join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi + + +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select a.tbname from sta a join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != tba2 then + return -1 +endi +sql_error select a.tbname from sta a join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi + + +#left join +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 64 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta a left join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),last(a.col1) from sta a left join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a left join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta a left join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta a left join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +sql select a.tbname from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 8 then + return -1 +endi +sql select count(b.*) from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +sql_error select a.tbname from sta a left join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta a left join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta a left join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + + +#left semi join +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),last(a.col1) from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a left semi join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta a left semi join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta a left semi join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 2 then + return -1 +endi +sql select count(b.col1) from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select count(b.ts) from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +sql select a.tbname from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +sql select count(b.*) from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +sql_error select a.tbname from sta a left semi join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select count(b.ts) from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select count(b.col1) from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 0 then + return -1 +endi +sql select count(b.col1) from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi +sql select count(b.ts) from sta a left semi join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta a left semi join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left semi join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left semi join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#left anti join +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),count(a.col1) from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a left anti join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta a left anti join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 5 then + return -1 +endi +if $data03 != 6 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 0 then + return -1 +endi +sql select count(b.ts) from sta a left anti join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 6 then + return -1 +endi +sql select count(b.col1) from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select count(b.ts) from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.tbname from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 7 then + return -1 +endi +sql select count(b.*) from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql_error select a.tbname from sta a left anti join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 5 then + return -1 +endi +sql select count(b.ts) from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 3 then + return -1 +endi +sql select count(b.col1) from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 2 then + return -1 +endi +sql select count(b.ts) from sta a left anti join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta a left anti join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left anti join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left anti join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#left asof join +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.ts >= b.ts and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select count(*),last(a.col1) from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql_error select count(*),count(a.col1) from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a left asof join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select count(b.ts) from sta a left asof join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts where b.col1 > 1 or a.col1 > 2; +if $rows != 7 then + return -1 +endi +sql_error select a.tbname from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql select a.tbname from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts where a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left asof join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts where a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select count(b.col1) from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi +sql select count(b.ts) from sta a left asof join sta b on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.tbname from sta a left asof join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left asof join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left asof join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#left window join +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) window_offset(-1s, 1s) where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h) window_offset(-1s, 1s); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 or a.col1 = b.col1 window_offset(-1s, 1s) where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.ts >= b.ts and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts window_offset(-1s, 1s); +sql_error select count(*),last(a.col1) from sta a left window join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 window_offset(-1s, 1s) where a.ts = b.ts and a.col1 > 2; +sql_error select count(*),count(a.col1) from sta a left window join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2 window_offset(-1s, 1s); +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a left window join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null window_offset(-1s, 1s) where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts) window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts window_offset(-1s, 1s); +sql_error select count(b.ts) from sta a left window join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 window_offset(-1s, 1s); +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 and a.col1 = b.col1 window_offset(-1s, 1s); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 and b.col1 > 1 window_offset(-1s, 1s); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.col1 > 1 or a.col1 > 2; +if $rows != 13 then + return -1 +endi +sql_error select a.tbname from sta a left window join sta b on a.t1 = b.t1 and a.col1 = b.col1 + 1 window_offset(-1s, 1s); +sql_error select a.tbname from sta a left window join sta b on a.t1 = b.t1 and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5 window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 and a.ts = b.ts window_offset(-1s, 1s) where a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 7 then + return -1 +endi +sql select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null having(count(a.ts) > 0); +sql select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1); +if $rows != 2 then + return -1 +endi +if $data00 != @23-11-17 16:29:00.000@ then + return -1 +endi +if $data10 != @23-11-17 16:29:04.000@ then + return -1 +endi +sql_error select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.col1; +sql_error select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.tbname; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.t1; +if $rows != 5 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 1 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +sql_error select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by b.col1; +sql select count(b.col1) c from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.col1, c; +if $rows != 5 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 +if $data40 != 1 then + return -1 +endi +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts > 0 and b.col1 is not null; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.tbname > 'a'; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.t1 > 1; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta a left window join sta b on a.col1 = b.col1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) where b.tbname > 'a'; +sql select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) where b.t1 > 1; +sql select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta a left window join tba1 b on a.col1 = b.col1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.tbname > 'tba1'; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi +sql select count(b.col1) from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s) where b.tbname < 'tba2'; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select count(b.col1) from sta a left window join tba2 b window_offset(-1s, 1s) where b.tbname < 'tba2'; +sql select count(b.col1) from sta a left window join tba2 b window_offset(-1s, 1s) where b.t1 < 2; +sql select count(b.col1) from sta a left window join tba2 b window_offset(-1s, 1s) where b.col1 < 1; +sql_error select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname; +sql_error select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.col1; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.t1; +sql_error select count(b.col1) from sta a left window join sta b window_offset(-1s, 1s) order by b.t1; +sql select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) order by b.tbname; +sql_error select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) order by b.col1; +sql select count(b.col1) from sta a left window join tba1 b window_offset(-1s, 1s) order by b.t1; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) order by a.tbname, a.ts; +if $rows != 8 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +sql select count(b.col1) from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname, a.ts; +if $rows != 8 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 0 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi + +sql_error select count(b.col1), b.tbname from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.t1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql_error select count(b.col1), b.col1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.col1 from sta a left window join sta b on a.col1 = b.col1 window_offset(-1s, 1s); +sql select count(b.col1), b.tbname from sta a left window join tba1 b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.t1 from sta a left window join tba1 b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.t1 from sta a left window join tba1 b window_offset(-1s, 1s); +sql_error select count(b.col1), b.col1 from sta a left window join tba1 b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.col1 from sta a left window join tba1 b on a.col1 = b.col1 window_offset(-1s, 1s); +sql select count(b.col1), b.col1 from sta a left window join sta b on a.col1 = b.col1 window_offset(-1s, 1s); +sql select count(b.col1), a.tbname from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), a.col1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), a.t1 from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.tbname from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s); +sql select first(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select first(a.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts > 0; +sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 > 0; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.tbname from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql select a.ts, a.col1, b.ts, b.col1 from sta a left window join sta b window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +sql_error select distinct count(b.col1) from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname, a.ts; +sql select distinct count(b.col1) c from sta a left window join tba2 b on a.t1 = b.t1 window_offset(-1s, 1s) order by c; +if $rows != 3 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 2 then + return -1 +endi + + diff --git a/tests/script/tsim/join/join_scalar2.sim b/tests/script/tsim/join/join_scalar2.sim new file mode 100644 index 0000000000..9cdef65055 --- /dev/null +++ b/tests/script/tsim/join/join_scalar2.sim @@ -0,0 +1,903 @@ +sql connect +sql use test0; + +##### conditions +sql use test0; + +#full join +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 64 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 16 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql_error select count(*),last(a.col1) from sta a full join sta b on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta a full join sta b on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; + +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 14 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 14 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 15 then + return -1 +endi +sql select a.tbname from sta a full join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 15 then + return -1 +endi +sql_error select a.tbname from sta a full join sta b on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 13 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 11 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 16 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 10 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta a full join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta a full join sta b where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta a full join sta b where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + +#right join +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 12 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 64 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta b right join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),last(a.col1) from sta b right join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta b right join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta b right join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 8 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta b right join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +sql select a.tbname from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 8 then + return -1 +endi +sql select count(b.*) from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +sql_error select a.tbname from sta b right join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta b right join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta b right join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + + +#right semi join +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),last(a.col1) from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi +if $data01 != 7 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta b right semi join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta b right semi join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 2 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 8 then + return -1 +endi +sql select count(b.ts) from sta b right semi join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 2 then + return -1 +endi +sql select count(b.col1) from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select count(b.ts) from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +sql select a.tbname from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +sql select count(b.*) from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +sql_error select a.tbname from sta b right semi join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select count(b.ts) from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select count(b.col1) from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 0 then + return -1 +endi +sql select count(b.col1) from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi +sql select count(b.ts) from sta b right semi join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta b right semi join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right semi join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right semi join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#right anti join +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select count(*),last(a.col1) from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql select count(*),count(a.col1) from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta b right anti join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql select first(b.col1),count(b.t1),last(a.col1),count(*) from sta b right anti join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null and a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 5 then + return -1 +endi +if $data03 != 6 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +if $rows != 0 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 0 then + return -1 +endi +sql select count(b.ts) from sta b right anti join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 6 then + return -1 +endi +sql select count(b.col1) from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 4 then + return -1 +endi +sql select count(b.ts) from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.tbname from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 7 then + return -1 +endi +sql select count(b.*) from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql_error select a.tbname from sta b right anti join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 5 then + return -1 +endi +sql select count(b.ts) from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 3 then + return -1 +endi +sql select count(b.col1) from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 2 then + return -1 +endi +sql select count(b.ts) from sta b right anti join sta a on a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi + + +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql_error select a.tbname from sta b right anti join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right anti join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right anti join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#right asof join +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts; +if $rows != 2 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) where a.ts = b.ts or a.ts != b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h); +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 or a.col1 = b.col1 where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.ts >= b.ts and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select count(*),last(a.col1) from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 where a.ts = b.ts and a.col1 > 2; +sql_error select count(*),count(a.col1) from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2; +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta b right asof join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql_error select count(b.ts) from sta b right asof join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 8 then + return -1 +endi +sql select count(b.col1) from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts where b.col1 > 1 or a.col1 > 2; +if $rows != 7 then + return -1 +endi +sql_error select a.tbname from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql select a.tbname from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts where a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right asof join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts where a.col1 > 2 and b.col1 < 5; +if $rows != 3 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 5 then + return -1 +endi +sql select count(b.col1) from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 1 then + return -1 +endi +if $data00 != 5 then + return -1 +endi +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or b.col1 > 3); +if $rows != 6 then + return -1 +endi +sql select count(b.ts) from sta b right asof join sta a on a.t1 = b.t1 and a.ts = b.ts where (a.col1 < 3 or b.col1 > 3); +if $rows != 1 then + return -1 +endi +if $data00 != 6 then + return -1 +endi + +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.tbname from sta b right asof join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right asof join sta a where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right asof join sta a where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); + + +#right window join +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on timetruncate(a.ts, 1h) = timetruncate(b.ts, 1h) window_offset(-1s, 1s) where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on timetruncate(a.ts, 1d) = timetruncate(b.ts, 1h) window_offset(-1s, 1s); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts = b.ts; +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 or a.col1 = b.col1 window_offset(-1s, 1s) where a.ts = b.ts; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.ts >= b.ts and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts window_offset(-1s, 1s); +sql_error select count(*),last(a.col1) from sta b right window join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 window_offset(-1s, 1s) where a.ts = b.ts and a.col1 > 2; +sql_error select count(*),count(a.col1) from sta b right window join sta a on (a.t1 = b.t1 or a.col1 > b.col1) and a.col1 > 1 and a.ts = b.ts and a.col1 > 2 window_offset(-1s, 1s); +sql_error select first(b.col1),count(b.t1),last(a.col1) from sta b right window join sta a on a.t1 = b.t1 and a.col1 > 1 and b.t1 is not null window_offset(-1s, 1s) where a.ts = b.ts and b.col1 > 3 and a.t1 != 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts) window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts window_offset(-1s, 1s); +sql_error select count(b.ts) from sta b right window join sta a on (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 window_offset(-1s, 1s); +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 and a.col1 = b.col1 window_offset(-1s, 1s); +if $rows != 8 then + return -1 +endi +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 and b.col1 > 1 window_offset(-1s, 1s); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.col1 > 1 or a.col1 > 2; +if $rows != 13 then + return -1 +endi +sql_error select a.tbname from sta b right window join sta a on a.t1 = b.t1 and a.col1 = b.col1 + 1 window_offset(-1s, 1s); +sql_error select a.tbname from sta b right window join sta a on a.t1 = b.t1 and count(a.col1) = 1; +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5 window_offset(-1s, 1s); +sql_error select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 and a.ts = b.ts window_offset(-1s, 1s) where a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +if $rows != 7 then + return -1 +endi +sql select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null having(count(a.ts) > 0); +sql select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1); +if $rows != 2 then + return -1 +endi +if $data00 != @23-11-17 16:29:00.000@ then + return -1 +endi +if $data10 != @23-11-17 16:29:04.000@ then + return -1 +endi +sql_error select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.col1; +sql_error select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.tbname; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.t1; +if $rows != 5 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 1 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +sql_error select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by b.col1; +sql select count(b.col1) c from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.col1, c; +if $rows != 5 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 +if $data40 != 1 then + return -1 +endi +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts > 0 and b.col1 is not null; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.tbname > 'a'; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.t1 > 1; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta b right window join sta a on a.col1 = b.col1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) where b.tbname > 'a'; +sql select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) where b.t1 > 1; +sql select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from tba1 b right window join sta a on a.col1 = b.col1 window_offset(-1s, 1s) where b.col1 > 1; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.tbname > 'tba1'; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi +sql select count(b.col1) from tba2 b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.tbname < 'tba2'; +if $rows != 1 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +sql select count(b.col1) from tba2 b right window join sta a window_offset(-1s, 1s) where b.tbname < 'tba2'; +sql select count(b.col1) from tba2 b right window join sta a window_offset(-1s, 1s) where b.t1 < 2; +sql select count(b.col1) from tba2 b right window join sta a window_offset(-1s, 1s) where b.col1 < 1; +sql_error select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname; +sql_error select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by b.col1; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by b.t1; +sql_error select count(b.col1) from sta b right window join sta a window_offset(-1s, 1s) order by b.t1; +sql select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) order by b.tbname; +sql_error select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) order by b.col1; +sql select count(b.col1) from tba1 b right window join sta a window_offset(-1s, 1s) order by b.t1; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by a.tbname, a.ts; +if $rows != 8 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +sql select count(b.col1) from tba2 b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname, a.ts; +if $rows != 8 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 0 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi + +sql_error select count(b.col1), b.tbname from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), a.tbname from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s); +sql select count(b.col1), b.tbname from tba2 b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s); +sql select first(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select first(a.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where b.ts > 0; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.ts > 0; +sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 > 0; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and (timetruncate(a.ts, 1h) = b.ts or a.ts = b.ts); +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where (a.t1 = b.t1 or a.col1 = b.col1) and timetruncate(a.ts, 1m) = b.ts; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and b.col1 > 1; +sql select a.tbname from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and a.col1 = b.col1 + 1; +sql_error select a.tbname from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and timetruncate(a.ts, 1m) = b.ts and count(a.col1) = 1; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and a.col1 > 2 and b.col1 < 5; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or a.col1 > 4) and b.col1 is null; +sql select a.ts, a.col1, b.ts, b.col1 from sta b right window join sta a window_offset(-1s, 1s) where a.t1 = b.t1 and a.ts = b.ts and (a.col1 < 3 or b.col1 > 3); +sql_error select distinct count(b.col1) from tba2 b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by b.tbname, a.ts; +sql select distinct count(b.col1) c from tba2 b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) order by c; +if $rows != 3 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 2 then + return -1 +endi + + diff --git a/tests/script/tsim/join/left_win_join.sim b/tests/script/tsim/join/left_win_join.sim index 0addf075d3..c0a9ddc906 100644 --- a/tests/script/tsim/join/left_win_join.sim +++ b/tests/script/tsim/join/left_win_join.sim @@ -984,8 +984,12 @@ endi if $data70 != 1 then return -1 endi +sql select a.col1, count(*) from sta a left window join sta b window_offset(-1s, 1s); +if $rows != 8 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 b.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 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(a.col1 > 0); diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 8c78a94de6..57ed675303 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -730,6 +730,10 @@ bool shellIsShowWhole(const char *sql) { if (taosStrCaseStr(sql, "show ") != NULL) { return true; } + // explain + if (taosStrCaseStr(sql, "explain ") != NULL) { + return true; + } return false; }