diff --git a/docs/en/14-reference/09-error-code.md b/docs/en/14-reference/09-error-code.md index d071bcdc81..725f5a22f5 100644 --- a/docs/en/14-reference/09-error-code.md +++ b/docs/en/14-reference/09-error-code.md @@ -462,8 +462,8 @@ This document details the server error codes that may be encountered when using | 0x80002688 | Cannot use 'year' or 'month' as true_for duration | Use year or month as true_for_duration | Check and correct the SQL statement | | 0x80002689 | Invalid using cols function | Illegal using cols function | Check and correct the SQL statement | | 0x8000268A | Cols function's first param must be a select function that output a single row | The first parameter of the cols function should be a selection function | Check and correct the SQL statement | -| 0x8000268B | Invalid using cols function with multiple output columns | Illegal using the cols function for multiple column output | Check and correct the SQL statement | -| 0x8000268C | Invalid using alias for cols function | Illegal cols function alias | Check and correct the SQL statement | +| 0x8000268B | Invalid using alias for cols function | Illegal cols function alias | Check and correct the SQL statement | +| 0x8000268C | Join primary key col must be timestmap type | Join primary key data type error | Check and correct the SQL statement | | 0x800026FF | Parser internal error | Internal error in parser | Preserve the scene and logs, report issue on GitHub | | 0x80002700 | Planner internal error | Internal error in planner | Preserve the scene and logs, report issue on GitHub | | 0x80002701 | Expect ts equal | JOIN condition validation failed | Preserve the scene and logs, report issue on GitHub | diff --git a/docs/zh/14-reference/09-error-code.md b/docs/zh/14-reference/09-error-code.md index 353ce16ed4..87809022dd 100644 --- a/docs/zh/14-reference/09-error-code.md +++ b/docs/zh/14-reference/09-error-code.md @@ -479,8 +479,8 @@ description: TDengine 服务端的错误码列表和详细说明 | 0x80002688 | Cannot use 'year' or 'month' as true_for duration | 不能使用 n(月), y(年) 作为 true_for 的时间单位 | 检查并修正 SQL 语句 | | 0x80002689 | Invalid using cols function | cols 函数使用错误 | 检查并修正 SQL 语句 | | 0x8000268A | Cols function's first param must be a select function that output a single row | cols 函数第一个参数应该为选择函数 | 检查并修正 SQL 语句 | -| 0x8000268B | Invalid using cols function with multiple output columns | 多列输出的 cols 函数使用错误 | 检查并修正 SQL 语句 | -| 0x8000268C | Invalid using alias for cols function | cols 函数输出列重命名错误 | 检查并修正 SQL 语句 | +| 0x8000268B | Invalid using alias for cols function | cols 函数输出列重命名错误 | 检查并修正 SQL 语句 | +| 0x8000268C | Join primary key col must be timestmap type | 关联查询主键列等值条件类型错误 | 检查并修正 SQL 语句 | | 0x800026FF | Parser internal error | 解析器内部错误 | 保留现场和日志,github上报issue | | 0x80002700 | Planner internal error | 计划期内部错误 | 保留现场和日志,github上报issue | | 0x80002701 | Expect ts equal | JOIN 条件校验失败 | 保留现场和日志,github上报issue | diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 9ed565090e..c79a7c4870 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -155,6 +155,13 @@ typedef struct SJoinLogicNode { bool grpJoin; bool hashJoinHint; bool batchScanHint; + + // FOR CONST JOIN + bool noPrimKeyEqCond; + bool leftConstPrimGot; + bool rightConstPrimGot; + bool leftNoOrderedSubQuery; + bool rightNoOrderedSubQuery; // FOR HASH JOIN int32_t timeRangeTarget; // table onCond filter diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 7191b4ef4a..47906e301f 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -57,10 +57,13 @@ typedef struct SExprNode { SDataType resType; char aliasName[TSDB_COL_NAME_LEN]; char userAlias[TSDB_COL_NAME_LEN]; + char srcTable[TSDB_TABLE_NAME_LEN]; SArray* pAssociation; bool asAlias; bool asParam; bool asPosition; + bool joinSrc; + //bool constValue; int32_t projIdx; int32_t relatedTo; int32_t bindExprID; @@ -209,6 +212,7 @@ typedef struct STableNode { char tableAlias[TSDB_TABLE_NAME_LEN]; uint8_t precision; bool singleTable; + bool inJoin; } STableNode; struct STableMeta; @@ -291,6 +295,10 @@ typedef struct SJoinTableNode { SNode* addPrimCond; bool hasSubQuery; bool isLowLevelJoin; + bool leftNoOrderedSubQuery; + bool rightNoOrderedSubQuery; + //bool condAlwaysTrue; + //bool condAlwaysFalse; SNode* pLeft; SNode* pRight; SNode* pOnCond; @@ -706,6 +714,8 @@ int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc); void rewriteExprAliasName(SExprNode* pNode, int64_t num); bool isRelatedToOtherExpr(SExprNode* pExpr); +bool nodesContainsColumn(SNode* pNode); +int32_t nodesMergeNode(SNode** pCond, SNode** pAdditionalCond); #ifdef __cplusplus } diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index d1dda544ae..3a1a14023c 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -33,6 +33,7 @@ pNode will be freed in API; */ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes); int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes); +int32_t scalarConvertOpValueNodeTs(SOperatorNode *node); /* pDst need to freed in caller diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 29e95251e9..66031f284a 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -913,8 +913,8 @@ int32_t taosGetErrSize(); #define TSDB_CODE_PAR_TRUE_FOR_UNIT TAOS_DEF_ERROR_CODE(0, 0x2688) #define TSDB_CODE_PAR_INVALID_COLS_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2689) #define TSDB_CODE_PAR_INVALID_COLS_SELECTFUNC TAOS_DEF_ERROR_CODE(0, 0x268A) -#define TSDB_CODE_INVALID_MULITI_COLS_FUNC TAOS_DEF_ERROR_CODE(0, 0x268B) -#define TSDB_CODE_INVALID_COLS_ALIAS TAOS_DEF_ERROR_CODE(0, 0x268C) +#define TSDB_CODE_PAR_INVALID_COLS_ALIAS TAOS_DEF_ERROR_CODE(0, 0x268B) +#define TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS TAOS_DEF_ERROR_CODE(0, 0x268C) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/source/libs/executor/inc/mergejoin.h b/source/libs/executor/inc/mergejoin.h index ceb0037b8d..52eb264639 100755 --- a/source/libs/executor/inc/mergejoin.h +++ b/source/libs/executor/inc/mergejoin.h @@ -40,6 +40,11 @@ typedef enum EJoinTableType { E_JOIN_TB_PROBE } EJoinTableType; +typedef enum EPrimExprType { + E_PRIM_TIMETRUNCATE = 1, + E_PRIM_VALUE +} EPrimExprType; + #define MJOIN_TBTYPE(_type) (E_JOIN_TB_BUILD == (_type) ? "BUILD" : "PROBE") #define IS_FULL_OUTER_JOIN(_jtype, _stype) ((_jtype) == JOIN_TYPE_FULL && (_stype) == JOIN_STYPE_OUTER) @@ -87,9 +92,15 @@ typedef struct SMJoinNMatchCtx { // for now timetruncate only typedef struct SMJoinPrimExprCtx { - int64_t truncateUnit; - int64_t timezoneUnit; - int32_t targetSlotId; + EPrimExprType type; + + // FOR TIMETRUNCATE + int64_t truncateUnit; + int64_t timezoneUnit; + int32_t targetSlotId; + + // FOR VALUE + int64_t constTs; } SMJoinPrimExprCtx; typedef struct SMJoinTableCtx { @@ -337,6 +348,8 @@ typedef struct SMJoinOperatorInfo { #define PROBE_TS_NREACH(_asc, _pts, _bts) (((_asc) && (_pts) > (_bts)) || (!(_asc) && (_pts) < (_bts))) #define MJOIN_BUILD_BLK_OOR(_asc, _pts, _pidx, _bts, _bnum) (((_asc) && (*((int64_t*)(_pts) + (_pidx)) > *((int64_t*)(_bts) + (_bnum) - 1))) || ((!(_asc)) && (*((int64_t*)(_pts) + (_pidx)) < *((int64_t*)(_bts) + (_bnum) - 1)))) +#define MJOIN_PRIM_EXPR_GOT(_pJoin) ((_pJoin)->probe->primCtx.type > 0 || (_pJoin)->build->primCtx.type > 0) + #define GRP_REMAIN_ROWS(_grp) ((_grp)->endIdx - (_grp)->readIdx + 1) #define GRP_DONE(_grp) ((_grp)->readIdx > (_grp)->endIdx) diff --git a/source/libs/executor/src/mergejoinoperator.c b/source/libs/executor/src/mergejoinoperator.c index 3edef48ed1..d7f7f0d085 100644 --- a/source/libs/executor/src/mergejoinoperator.c +++ b/source/libs/executor/src/mergejoinoperator.c @@ -894,21 +894,7 @@ static int32_t mJoinInitFinColsInfo(SMJoinTableCtx* pTable, SNodeList* pList) { return TSDB_CODE_SUCCESS; } -static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoinTableCtx* pTable) { - if (NULL == pNode) { - pCtx->targetSlotId = pTable->primCol->srcSlot; - return TSDB_CODE_SUCCESS; - } - - if (QUERY_NODE_TARGET != nodeType(pNode)) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - - STargetNode* pTarget = (STargetNode*)pNode; - if (QUERY_NODE_FUNCTION != nodeType(pTarget->pExpr)) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - +static int32_t mJoinInitFuncPrimExprCtx(SMJoinPrimExprCtx* pCtx, STargetNode* pTarget) { SFunctionNode* pFunc = (SFunctionNode*)pTarget->pExpr; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; @@ -939,6 +925,47 @@ static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoi pCtx->timezoneUnit = offsetFromTz(varDataVal(pTimeZone->datum.p), TSDB_TICK_PER_SECOND(pFunc->node.resType.precision)); } + pCtx->type = E_PRIM_TIMETRUNCATE; + + return TSDB_CODE_SUCCESS; +} + +static int32_t mJoinInitValPrimExprCtx(SMJoinPrimExprCtx* pCtx, STargetNode* pTarget) { + SValueNode* pVal = (SValueNode*)pTarget->pExpr; + if (TSDB_DATA_TYPE_TIMESTAMP != pVal->node.resType.type) { + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + pCtx->constTs = pVal->datum.i; + pCtx->type = E_PRIM_VALUE; + + return TSDB_CODE_SUCCESS; +} + + +static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoinTableCtx* pTable) { + if (NULL == pNode) { + pCtx->targetSlotId = pTable->primCol->srcSlot; + return TSDB_CODE_SUCCESS; + } + + if (QUERY_NODE_TARGET != nodeType(pNode)) { + qError("primary expr node is not target, type:%d", nodeType(pNode)); + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + STargetNode* pTarget = (STargetNode*)pNode; + if (QUERY_NODE_FUNCTION != nodeType(pTarget->pExpr) && QUERY_NODE_VALUE != nodeType(pTarget->pExpr)) { + qError("Invalid primary expr node type:%d", nodeType(pTarget->pExpr)); + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + if (QUERY_NODE_FUNCTION == nodeType(pTarget->pExpr)) { + MJ_ERR_RET(mJoinInitFuncPrimExprCtx(pCtx, pTarget)); + } else if (QUERY_NODE_VALUE == nodeType(pTarget->pExpr)) { + MJ_ERR_RET(mJoinInitValPrimExprCtx(pCtx, pTarget)); + } + pCtx->targetSlotId = pTarget->slotId; return TSDB_CODE_SUCCESS; @@ -1045,25 +1072,36 @@ int32_t mJoinLaunchPrimExpr(SSDataBlock* pBlock, SMJoinTableCtx* pTable) { return TSDB_CODE_SUCCESS; } - SMJoinPrimExprCtx* pCtx = &pTable->primCtx; - SColumnInfoData* pPrimIn = taosArrayGet(pBlock->pDataBlock, pTable->primCol->srcSlot); - if (NULL == pPrimIn) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - SColumnInfoData* pPrimOut = taosArrayGet(pBlock->pDataBlock, pTable->primCtx.targetSlotId); if (NULL == pPrimOut) { return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; } - if (0 != pCtx->timezoneUnit) { - for (int32_t i = 0; i < pBlock->info.rows; ++i) { - ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] - (((int64_t*)pPrimIn->pData)[i] + pCtx->timezoneUnit) % pCtx->truncateUnit; + SMJoinPrimExprCtx* pCtx = &pTable->primCtx; + switch (pCtx->type) { + case E_PRIM_TIMETRUNCATE: { + SColumnInfoData* pPrimIn = taosArrayGet(pBlock->pDataBlock, pTable->primCol->srcSlot); + if (NULL == pPrimIn) { + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + if (0 != pCtx->timezoneUnit) { + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] - (((int64_t*)pPrimIn->pData)[i] + pCtx->timezoneUnit) % pCtx->truncateUnit; + } + } else { + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] / pCtx->truncateUnit * pCtx->truncateUnit; + } + } + break; } - } else { - for (int32_t i = 0; i < pBlock->info.rows; ++i) { - ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] / pCtx->truncateUnit * pCtx->truncateUnit; + case E_PRIM_VALUE: { + MJ_ERR_RET(colDataSetNItems(pPrimOut, 0, (char*)&pCtx->constTs, pBlock->info.rows, false)); + break; } + default: + break; } return TSDB_CODE_SUCCESS; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index fcb39c4284..1f5155a689 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -102,9 +102,11 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); + COPY_CHAR_ARRAY_FIELD(srcTable); COPY_SCALAR_FIELD(asAlias); COPY_SCALAR_FIELD(asParam); COPY_SCALAR_FIELD(asPosition); + COPY_SCALAR_FIELD(joinSrc); COPY_SCALAR_FIELD(projIdx); COPY_SCALAR_FIELD(relatedTo); COPY_SCALAR_FIELD(bindExprID); @@ -242,6 +244,7 @@ static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { COPY_CHAR_ARRAY_FIELD(tableAlias); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(singleTable); + COPY_SCALAR_FIELD(inJoin); return TSDB_CODE_SUCCESS; } @@ -321,6 +324,10 @@ static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDs CLONE_NODE_FIELD(addPrimCond); COPY_SCALAR_FIELD(hasSubQuery); COPY_SCALAR_FIELD(isLowLevelJoin); + COPY_SCALAR_FIELD(leftNoOrderedSubQuery); + COPY_SCALAR_FIELD(rightNoOrderedSubQuery); + //COPY_SCALAR_FIELD(condAlwaysTrue); + //COPY_SCALAR_FIELD(condAlwaysFalse); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); CLONE_NODE_FIELD(pOnCond); @@ -542,6 +549,11 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { COPY_SCALAR_FIELD(grpJoin); COPY_SCALAR_FIELD(hashJoinHint); COPY_SCALAR_FIELD(batchScanHint); + COPY_SCALAR_FIELD(noPrimKeyEqCond); + COPY_SCALAR_FIELD(leftConstPrimGot); + COPY_SCALAR_FIELD(rightConstPrimGot); + COPY_SCALAR_FIELD(leftNoOrderedSubQuery); + COPY_SCALAR_FIELD(rightNoOrderedSubQuery); CLONE_NODE_FIELD(pLeftOnCond); CLONE_NODE_FIELD(pRightOnCond); COPY_SCALAR_FIELD(timeRangeTarget); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 9b7d9e53bf..23f647aa16 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -3280,3 +3280,76 @@ void rewriteExprAliasName(SExprNode* pNode, int64_t num) { bool isRelatedToOtherExpr(SExprNode* pExpr) { return pExpr->relatedTo != 0; } + +typedef struct SContainsColCxt { + bool containsCol; +} SContainsColCxt; + +static EDealRes nodeContainsCol(SNode* pNode, void* pContext) { + SContainsColCxt* pCxt = pContext; + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + pCxt->containsCol = true; + return DEAL_RES_END; + } + + return DEAL_RES_CONTINUE; +} + +bool nodesContainsColumn(SNode* pNode) { + if (NULL == pNode) { + return false; + } + + SContainsColCxt cxt = {0}; + nodesWalkExpr(pNode, nodeContainsCol, &cxt); + + return cxt.containsCol; +} + + + +int32_t mergeNodeToLogic(SNode** pDst, SNode** pSrc) { + SLogicConditionNode* pLogicCond = NULL; + int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond); + if (NULL == pLogicCond) { + return code; + } + pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL; + pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + pLogicCond->condType = LOGIC_COND_TYPE_AND; + code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc); + if (TSDB_CODE_SUCCESS == code) { + *pSrc = NULL; + code = nodesListMakeAppend(&pLogicCond->pParameterList, *pDst); + } + if (TSDB_CODE_SUCCESS == code) { + *pDst = (SNode*)pLogicCond; + } else { + nodesDestroyNode((SNode*)pLogicCond); + } + return code; +} + + +int32_t nodesMergeNode(SNode** pCond, SNode** pAdditionalCond) { + if (NULL == *pCond) { + TSWAP(*pCond, *pAdditionalCond); + return TSDB_CODE_SUCCESS; + } + + int32_t code = TSDB_CODE_SUCCESS; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCond)->condType) { + code = nodesListAppend(((SLogicConditionNode*)*pCond)->pParameterList, *pAdditionalCond); + if (TSDB_CODE_SUCCESS == code) { + *pAdditionalCond = NULL; + } + } else { + code = mergeNodeToLogic(pCond, pAdditionalCond); + } + + return code; +} + + + diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index 5999ada70f..4b5d106318 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -42,12 +42,12 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDa int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues); -int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinParent); +int32_t translateTable(STranslateContext* pCxt, SNode** pTable, bool inJoin); int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput); void tfreeSParseQueryRes(void* p); #ifdef TD_ENTERPRISE -int32_t translateView(STranslateContext* pCxt, SNode** pTable, SName* pName); +int32_t translateView(STranslateContext* pCxt, SNode** pTable, SName* pName, bool inJoin); int32_t getViewMetaFromMetaCache(STranslateContext* pCxt, SName* pName, SViewMeta** ppViewMeta); #endif #ifdef __cplusplus diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 0f8c8ee034..e787ac4ba2 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -118,6 +118,39 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SNode** pNode) { return code; } +static EDealRes rewriteCalcConstValue(SNode** pNode, void* pContext) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; + SCalcConstContext* pCtx = (SCalcConstContext*)pContext; + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pNode)) { + return DEAL_RES_CONTINUE; + } else if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { + SOperatorNode* pOp = (SOperatorNode*)*pNode; + if (OP_TYPE_EQUAL == pOp->opType && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pLeft)->resType.type || TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pRight)->resType.type)) { + code = calcConstNode(&pOp->pLeft); + if (TSDB_CODE_SUCCESS == code) { + code = calcConstNode(&pOp->pRight); + } + + goto _end; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = calcConstCondition(pCtx, pNode); + } + +_end: + + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + return DEAL_RES_ERROR; + } + + return DEAL_RES_IGNORE_CHILD; +} + static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -127,13 +160,32 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab } case QUERY_NODE_JOIN_TABLE: { SJoinTableNode* pJoin = (SJoinTableNode*)pTable; + SNode* pCond = NULL; code = rewriteConditionForFromTable(pCxt, pJoin->pLeft); if (TSDB_CODE_SUCCESS == code) { code = rewriteConditionForFromTable(pCxt, pJoin->pRight); } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + code = rewriteCondition(pCxt, &pJoin->pOnCond); + } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + nodesRewriteExpr(&pJoin->pOnCond, rewriteCalcConstValue, pCxt); + } + +/* + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + code = nodesCloneNode(pJoin->pOnCond, &pCond); + } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { code = calcConstCondition(pCxt, &pJoin->pOnCond); } + if (TSDB_CODE_SUCCESS == code && pJoin->pOnCond && QUERY_NODE_VALUE == nodeType(pJoin->pOnCond)) { + nodesDestroyNode(pJoin->pOnCond); + pJoin->pOnCond = pCond; + pCond = NULL; + } + nodesDestroyNode(pCond); +*/ // todo empty table break; } @@ -207,6 +259,7 @@ static int32_t findAndReplaceNode(SCalcConstContext* pCxt, SNode** pRoot, SNode* static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool dual, SNode** pNew) { SArray* pAssociation = NULL; + if (NULL != ((SExprNode*)pProject)->pAssociation) { pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation, NULL); if (NULL == pAssociation) { @@ -214,7 +267,7 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d } } - char aliasName[TSDB_COL_NAME_LEN] = {0}; + char aliasName[TSDB_COL_NAME_LEN] = {0}, srcTable[TSDB_TABLE_NAME_LEN] = {0}; int32_t code = TSDB_CODE_SUCCESS; if (dual) { code = scalarCalculateConstantsFromDual(pProject, pNew); @@ -227,8 +280,16 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d for (int32_t i = 0; i < size; ++i) { SAssociationNode* pAssNode = taosArrayGet(pAssociation, i); SNode** pCol = pAssNode->pPlace; + if (((SExprNode*)pAssNode->pAssociationNode)->joinSrc) { + //((SExprNode*)pAssNode->pAssociationNode)->constValue = true; + continue; + } + if (*pCol == pAssNode->pAssociationNode) { tstrncpy(aliasName, ((SExprNode*)*pCol)->aliasName, TSDB_COL_NAME_LEN); + if (QUERY_NODE_COLUMN == nodeType(*pCol)) { + tstrncpy(srcTable, ((SColumnNode*)*pCol)->tableAlias, TSDB_TABLE_NAME_LEN); + } SArray* pOrigAss = NULL; TSWAP(((SExprNode*)*pCol)->pAssociation, pOrigAss); nodesDestroyNode(*pCol); @@ -236,6 +297,9 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d code = nodesCloneNode(*pNew, pCol); if (TSDB_CODE_SUCCESS == code) { tstrncpy(((SExprNode*)*pCol)->aliasName, aliasName, TSDB_COL_NAME_LEN); + if (srcTable[0]) { + tstrncpy(((SExprNode*)*pCol)->srcTable, srcTable, TSDB_TABLE_NAME_LEN); + } TSWAP(pOrigAss, ((SExprNode*)*pCol)->pAssociation); } taosArrayDestroy(pOrigAss); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 182c5965ad..9d472fab80 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1383,7 +1383,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p pCol->numOfPKs = pTable->pMeta->tableInfo.numOfPKs; } -static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef) { +static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef, bool joinSrc) { SColumnNode* pCol = *pColRef; if (NULL == pExpr->pAssociation) { @@ -1413,6 +1413,7 @@ static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SCo tstrncpy(pCol->node.userAlias, pExpr->userAlias, TSDB_COL_NAME_LEN); } pCol->node.resType = pExpr->resType; + pCol->node.joinSrc = pTable->table.inJoin && joinSrc; return TSDB_CODE_SUCCESS; } @@ -1494,7 +1495,7 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p code = nodesListStrictAppend(pList, (SNode*)pCol); if (TSDB_CODE_SUCCESS == code) { SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); - code = setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); + code = setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode, true); } if (TSDB_CODE_SUCCESS == code) { if (!skipProjRef) @@ -1591,7 +1592,7 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, } } if (pFoundExpr) { - code = setColumnInfoByExpr(pTempTable, pFoundExpr, pColRef); + code = setColumnInfoByExpr(pTempTable, pFoundExpr, pColRef, SQL_CLAUSE_FROM != pCxt->currClause); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -4753,14 +4754,25 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl } } - if ((QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) && - !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) || - (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) && - !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery))) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, - "Join requires valid time series input"); + if (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) && + !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) { + if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, + "Join requires valid time series input"); + } + pJoinTable->leftNoOrderedSubQuery = true; } + if (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) && + !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery)) { + if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, + "Join requires valid time series input"); + } + pJoinTable->rightNoOrderedSubQuery = true; + } + + return TSDB_CODE_SUCCESS; } @@ -5088,9 +5100,141 @@ static int32_t setJoinTimeLineResMode(STranslateContext* pCxt) { return TSDB_CODE_SUCCESS; } -int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinParent) { +int32_t mergeInnerJoinConds(SNode** ppDst, SNode** ppSrc) { + SNode* pNew = NULL; + int32_t code = TSDB_CODE_SUCCESS; + + while (true) { + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppDst) && ((SLogicConditionNode*)*ppDst)->condType == LOGIC_COND_TYPE_AND) { + SLogicConditionNode* pLogic = (SLogicConditionNode*)*ppDst; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + SLogicConditionNode* pSrcLogic = (SLogicConditionNode*)*ppSrc; + code = nodesListMakeStrictAppendList(&pLogic->pParameterList, pSrcLogic->pParameterList); + if (TSDB_CODE_SUCCESS == code) { + pSrcLogic->pParameterList = NULL; + nodesDestroyNode(*ppSrc); + *ppSrc = NULL; + } + } else { + code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); + if (TSDB_CODE_SUCCESS == code) { + *ppSrc = NULL; + } + } + + return code; + } + + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + SNode* pTmp = *ppDst; + *ppDst = *ppSrc; + *ppSrc = pTmp; + continue; + } + + if (TSDB_CODE_SUCCESS == code) { + code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &pNew); + } + if (TSDB_CODE_SUCCESS == code) { + SLogicConditionNode* pLogic = (SLogicConditionNode*)pNew; + pLogic->condType = LOGIC_COND_TYPE_AND; + pLogic->node.resType.type = TSDB_DATA_TYPE_BOOL; + pLogic->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); + if (TSDB_CODE_SUCCESS == code) { + *ppSrc = *ppDst; + *ppDst = pNew; + continue; + } + } + + if (code) { + break; + } + } + + return code; +} + +bool isColumnExpr(SNode* pNode) { + SExprNode* pExpr = (SExprNode*)pNode; + if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode)) { + return false; + } + if (QUERY_NODE_FUNCTION == nodeType(pNode)) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType && strcasecmp(((SFunctionNode*)pNode)->functionName, "timetruncate")) { + return false; + } + if (!nodesContainsColumn(nodesListGetNode(pFunc->pParameterList, 0))) { + return false; + } + } + + return true; +} + +int32_t splitJoinColPrimaryCond(SNode** ppSrc, SNode** ppDst) { + if (NULL == *ppSrc) { + return TSDB_CODE_SUCCESS; + } + + int32_t code = 0; + switch (nodeType(*ppSrc)) { + case QUERY_NODE_OPERATOR: { + SOperatorNode* pOp = (SOperatorNode*)*ppSrc; + if (OP_TYPE_EQUAL != pOp->opType) { + break; + } + if (isColumnExpr(pOp->pLeft) && isColumnExpr(pOp->pRight)) { + TSWAP(*ppSrc, *ppDst); + } + break; + } + case QUERY_NODE_LOGIC_CONDITION: { + SLogicConditionNode* pLogic = (SLogicConditionNode*)*ppSrc; + if (LOGIC_COND_TYPE_AND != pLogic->condType) { + break; + } + SNode* pTmp = NULL; + SNode* pTmpRes = NULL; + WHERE_EACH(pTmp, pLogic->pParameterList) { + code = splitJoinColPrimaryCond(&pTmp, &pTmpRes); + if (code) { + break; + } + if (NULL == pTmp && NULL != pTmpRes) { + cell->pNode = NULL; + ERASE_NODE(pLogic->pParameterList); + code = nodesMergeNode(ppDst, &pTmpRes); + if (code) { + break; + } + + continue; + } + + WHERE_NEXT; + } + if (pLogic->pParameterList->length <= 0) { + nodesDestroyNode(*ppSrc); + *ppSrc = NULL; + } + break; + } + default: + break; + } + + return code; +} + +int32_t translateTable(STranslateContext* pCxt, SNode** pTable, bool inJoin) { SSelectStmt* pCurrSmt = (SSelectStmt*)(pCxt->pCurrStmt); int32_t code = TSDB_CODE_SUCCESS; + + ((STableNode*)*pTable)->inJoin = inJoin; + switch (nodeType(*pTable)) { case QUERY_NODE_REAL_TABLE: { SRealTableNode* pRealTable = (SRealTableNode*)*pTable; @@ -5106,7 +5250,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare } #ifdef TD_ENTERPRISE if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType && (!pCurrSmt->tagScan || pCxt->pParseCxt->biMode)) { - return translateView(pCxt, pTable, &name); + return translateView(pCxt, pTable, &name, inJoin); } code = translateAudit(pCxt, pRealTable, &name); #endif @@ -5163,14 +5307,27 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare SJoinTableNode* pJoinTable = (SJoinTableNode*)*pTable; code = translateJoinTable(pCxt, pJoinTable); if (TSDB_CODE_SUCCESS == code) { - code = translateTable(pCxt, &pJoinTable->pLeft, (SNode*)pJoinTable); + code = translateTable(pCxt, &pJoinTable->pLeft, true); } if (TSDB_CODE_SUCCESS == code) { - code = translateTable(pCxt, &pJoinTable->pRight, (SNode*)pJoinTable); + code = translateTable(pCxt, &pJoinTable->pRight, true); } if (TSDB_CODE_SUCCESS == code) { code = checkJoinTable(pCxt, pJoinTable); } + if (TSDB_CODE_SUCCESS == code && !inJoin && pCurrSmt->pWhere && JOIN_TYPE_INNER == pJoinTable->joinType) { + SNode* pPrimCond = NULL; + code = splitJoinColPrimaryCond(&pCurrSmt->pWhere, &pPrimCond); + if (TSDB_CODE_SUCCESS == code && pPrimCond) { + if (pJoinTable->pOnCond) { + code = mergeInnerJoinConds(&pJoinTable->pOnCond, &pPrimCond); + } else { + pJoinTable->pOnCond = pPrimCond; + pPrimCond = NULL; + } + } + nodesDestroyNode(pPrimCond); + } if (TSDB_CODE_SUCCESS == code) { pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable); pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable); @@ -7123,7 +7280,7 @@ static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) { static int32_t translateFrom(STranslateContext* pCxt, SNode** pTable) { pCxt->currClause = SQL_CLAUSE_FROM; - return translateTable(pCxt, pTable, NULL); + return translateTable(pCxt, pTable, false); } static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -7555,7 +7712,7 @@ static EDealRes rewriteSingleColsFunc(SNode** pNode, void* pContext) { } if (pFunc->node.asAlias) { if (((SExprNode*)pExpr)->asAlias) { - pCxt->status = TSDB_CODE_INVALID_COLS_ALIAS; + pCxt->status = TSDB_CODE_PAR_INVALID_COLS_ALIAS; parserError("%s Invalid using alias for cols function", __func__); return DEAL_RES_ERROR; } else { @@ -7664,7 +7821,7 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList if (isMultiColsFuncNode(pTmpNode)) { SFunctionNode* pFunc = (SFunctionNode*)pTmpNode; if(pFunc->node.asAlias) { - code = TSDB_CODE_INVALID_COLS_ALIAS; + code = TSDB_CODE_PAR_INVALID_COLS_ALIAS; parserError("%s Invalid using alias for cols function", __func__); goto _end; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 98b2ef341e..d88bcb6f4b 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -600,6 +600,9 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pJoin->node.requireDataOrder = pJoin->hashJoinHint ? DATA_ORDER_LEVEL_NONE : DATA_ORDER_LEVEL_GLOBAL; pJoin->node.resultDataOrder = DATA_ORDER_LEVEL_NONE; pJoin->isLowLevelJoin = pJoinTable->isLowLevelJoin; + pJoin->leftNoOrderedSubQuery = pJoinTable->leftNoOrderedSubQuery; + pJoin->rightNoOrderedSubQuery = pJoinTable->leftNoOrderedSubQuery; + code = nodesCloneNode(pJoinTable->pWindowOffset, &pJoin->pWindowOffset); if (TSDB_CODE_SUCCESS == code) { code = nodesCloneNode(pJoinTable->pJLimit, &pJoin->pJLimit); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 608b531d3c..3378202274 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -20,6 +20,7 @@ #include "systable.h" #include "tglobal.h" #include "ttime.h" +#include "scalar.h" #define OPTIMIZE_FLAG_MASK(n) (1 << n) @@ -502,52 +503,12 @@ static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub return code; } -static int32_t pdcMergeCondsToLogic(SNode** pDst, SNode** pSrc) { - SLogicConditionNode* pLogicCond = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond); - if (NULL == pLogicCond) { - return code; - } - pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL; - pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; - pLogicCond->condType = LOGIC_COND_TYPE_AND; - code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc); - if (TSDB_CODE_SUCCESS == code) { - *pSrc = NULL; - code = nodesListMakeAppend(&pLogicCond->pParameterList, *pDst); - } - if (TSDB_CODE_SUCCESS == code) { - *pDst = (SNode*)pLogicCond; - } else { - nodesDestroyNode((SNode*)pLogicCond); - } - return code; -} - -static int32_t pdcMergeConds(SNode** pCond, SNode** pAdditionalCond) { - if (NULL == *pCond) { - TSWAP(*pCond, *pAdditionalCond); - return TSDB_CODE_SUCCESS; - } - - int32_t code = TSDB_CODE_SUCCESS; - if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond) && - LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCond)->condType) { - code = nodesListAppend(((SLogicConditionNode*)*pCond)->pParameterList, *pAdditionalCond); - if (TSDB_CODE_SUCCESS == code) { - *pAdditionalCond = NULL; - } - } else { - code = pdcMergeCondsToLogic(pCond, pAdditionalCond); - } - return code; -} static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pOtherCond) { int32_t code = TSDB_CODE_SUCCESS; if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { - code = pdcMergeConds(pOtherCond, pPrimaryKeyCond); + code = nodesMergeNode(pOtherCond, pPrimaryKeyCond); } else { bool isStrict = false; code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); @@ -555,7 +516,7 @@ static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNo if (isStrict) { nodesDestroyNode(*pPrimaryKeyCond); } else { - code = pdcMergeConds(pOtherCond, pPrimaryKeyCond); + code = nodesMergeNode(pOtherCond, pPrimaryKeyCond); } *pPrimaryKeyCond = NULL; } @@ -629,8 +590,16 @@ static bool pdcJoinColInTableColList(SNode* pNode, SNodeList* pTableCols) { } static bool pdcJoinColInTableList(SNode* pCondCol, SSHashObj* pTables) { - SColumnNode* pTableCol = (SColumnNode*)pCondCol; - if (NULL == tSimpleHashGet(pTables, pTableCol->tableAlias, strlen(pTableCol->tableAlias))) { + char* pTableAlias = NULL; + if (QUERY_NODE_COLUMN == nodeType(pCondCol)) { + SColumnNode* pTableCol = (SColumnNode*)pCondCol; + pTableAlias = pTableCol->tableAlias; + } else if (QUERY_NODE_VALUE == nodeType(pCondCol)) { + SValueNode* pVal = (SValueNode*)pCondCol; + pTableAlias = pVal->node.srcTable; + } + + if (NULL == tSimpleHashGet(pTables, pTableAlias, strlen(pTableAlias))) { return false; } return true; @@ -819,15 +788,27 @@ static int32_t pdcJoinSplitCond(SJoinLogicNode* pJoin, SNode** pSrcCond, SNode** } static int32_t pdcJoinPushDownOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** pCond) { - return pdcMergeConds(&pJoin->pFullOnCond, pCond); + return nodesMergeNode(&pJoin->pFullOnCond, pCond); } static int32_t pdcPushDownCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) { - return pdcMergeConds(&pChild->pConditions, pCond); + return nodesMergeNode(&pChild->pConditions, pCond); } -static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables) { - if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode)) { +static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables, bool constAsPrim, bool* constPrimGot) { + if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode) && (!constAsPrim || QUERY_NODE_VALUE != nodeType(pNode))) { + return false; + } + + if (QUERY_NODE_VALUE == nodeType(pNode)) { + SValueNode* pVal = (SValueNode*)pNode; + if (TSDB_DATA_TYPE_NULL != pVal->node.resType.type && !pVal->isNull) { + if (pdcJoinColInTableList(pNode, pTables)) { + *constPrimGot = true; + return true; + } + } + return false; } @@ -850,7 +831,7 @@ static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables) { return pdcJoinColInTableList(pNode, pTables); } -static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { +static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond, bool constAsPrim) { if (QUERY_NODE_OPERATOR != nodeType(pCond)) { return false; } @@ -878,11 +859,14 @@ static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { return code; } - bool res = false; - if (pdcJoinIsPrim(pOper->pLeft, pLeftTables)) { - res = pdcJoinIsPrim(pOper->pRight, pRightTables); - } else if (pdcJoinIsPrim(pOper->pLeft, pRightTables)) { - res = pdcJoinIsPrim(pOper->pRight, pLeftTables); + bool res = false, constGot = false; + if (pdcJoinIsPrim(pOper->pLeft, pLeftTables, constAsPrim, &pJoin->leftConstPrimGot)) { + res = pdcJoinIsPrim(pOper->pRight, pRightTables, constAsPrim, &pJoin->rightConstPrimGot); + } else if (pdcJoinIsPrim(pOper->pLeft, pRightTables, constAsPrim, &pJoin->rightConstPrimGot)) { + res = pdcJoinIsPrim(pOper->pRight, pLeftTables, constAsPrim, &pJoin->leftConstPrimGot); + if (pJoin->rightConstPrimGot || pJoin->leftConstPrimGot) { + TSWAP(pOper->pLeft, pOper->pRight); + } } tSimpleHashCleanup(pLeftTables); @@ -910,24 +894,26 @@ static bool pdcJoinHasPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond, bool* e } return hasPrimaryKeyEqualCond; } else { - return pdcJoinIsPrimEqualCond(pJoin, pCond); + return pdcJoinIsPrimEqualCond(pJoin, pCond, false); } } -static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppPrimEqCond, SNode** ppOnCond) { - SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(pJoin->pFullOnCond); +static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppInput, SNode** ppPrimEqCond, SNode** ppOnCond, bool constAsPrim) { + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*ppInput); int32_t code = TSDB_CODE_SUCCESS; SNodeList* pOnConds = NULL; SNode* pCond = NULL; WHERE_EACH(pCond, pLogicCond->pParameterList) { SNode* pNew = NULL; - code = nodesCloneNode(pCond, &pNew); - if (TSDB_CODE_SUCCESS != code) break; - if (pdcJoinIsPrimEqualCond(pJoin, pCond) && (NULL == *ppPrimEqCond)) { + if (pdcJoinIsPrimEqualCond(pJoin, pCond, constAsPrim) && (NULL == *ppPrimEqCond) && (!constAsPrim || pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { + code = nodesCloneNode(pCond, &pNew); + if (TSDB_CODE_SUCCESS != code) break; *ppPrimEqCond = pNew; ERASE_NODE(pLogicCond->pParameterList); } else { + code = nodesCloneNode(pCond, &pNew); + if (TSDB_CODE_SUCCESS != code) break; code = nodesListMakeAppend(&pOnConds, pNew); if (TSDB_CODE_SUCCESS != code) break; WHERE_NEXT; @@ -942,10 +928,11 @@ static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppPrim if (TSDB_CODE_SUCCESS == code) { if (NULL != *ppPrimEqCond) { *ppOnCond = pTempOnCond; - nodesDestroyNode(pJoin->pFullOnCond); - pJoin->pFullOnCond = NULL; + nodesDestroyNode(*ppInput); + *ppInput = NULL; return TSDB_CODE_SUCCESS; } + nodesDestroyNode(pTempOnCond); planError("no primary key equal cond found, condListNum:%d", pLogicCond->pParameterList->length); return TSDB_CODE_PLAN_INTERNAL_ERROR; } else { @@ -962,8 +949,8 @@ static int32_t pdcJoinSplitPrimEqCond(SOptimizeContext* pCxt, SJoinLogicNode* pJ if (QUERY_NODE_LOGIC_CONDITION == nodeType(pJoin->pFullOnCond) && LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)(pJoin->pFullOnCond))->condType) { - code = pdcJoinSplitPrimInLogicCond(pJoin, &pPrimKeyEqCond, &pJoinOnCond); - } else if (pdcJoinIsPrimEqualCond(pJoin, pJoin->pFullOnCond)) { + code = pdcJoinSplitPrimInLogicCond(pJoin, &pJoin->pFullOnCond, &pPrimKeyEqCond, &pJoinOnCond, false); + } else if (pdcJoinIsPrimEqualCond(pJoin, pJoin->pFullOnCond, false)) { pPrimKeyEqCond = pJoin->pFullOnCond; pJoinOnCond = NULL; } else { @@ -1412,6 +1399,37 @@ static int32_t pdcJoinAddFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogicNo return code; } +static int32_t pdcJoinSplitConstPrimEqCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** ppCond) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pPrimKeyEqCond = NULL; + SNode* pJoinOnCond = NULL; + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*ppCond)->condType) { + code = pdcJoinSplitPrimInLogicCond(pJoin, ppCond, &pPrimKeyEqCond, &pJoinOnCond, true); + } else if (pdcJoinIsPrimEqualCond(pJoin, *ppCond, true) && (pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { + pPrimKeyEqCond = *ppCond; + pJoinOnCond = NULL; + } else { + return TSDB_CODE_SUCCESS; + } + + if (TSDB_CODE_SUCCESS == code) { + pJoin->pPrimKeyEqCond = pPrimKeyEqCond; + *ppCond = pJoinOnCond; + if (pJoin->rightConstPrimGot || pJoin->leftConstPrimGot) { + code = scalarConvertOpValueNodeTs((SOperatorNode*)pJoin->pPrimKeyEqCond); + } + } else { + nodesDestroyNode(pPrimKeyEqCond); + nodesDestroyNode(pJoinOnCond); + } + + return code; +} + + + static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { if (NULL == pJoin->pFullOnCond) { if (IS_WINDOW_JOIN(pJoin->subType) || IS_ASOF_JOIN(pJoin->subType)) { @@ -1427,9 +1445,10 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin } } - SNode* pCond = pJoin->pFullOnCond ? pJoin->pFullOnCond : pJoin->node.pConditions; + SNode** ppCond = pJoin->pFullOnCond ? &pJoin->pFullOnCond : &pJoin->node.pConditions; bool errCond = false; - if (!pdcJoinHasPrimEqualCond(pJoin, pCond, &errCond)) { + bool primCondGot = pdcJoinHasPrimEqualCond(pJoin, *ppCond, &errCond); + if (!primCondGot) { 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); @@ -1437,7 +1456,8 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin if (IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && NULL != pJoin->node.pConditions) { - if (pdcJoinHasPrimEqualCond(pJoin, pJoin->node.pConditions, &errCond)) { + primCondGot = pdcJoinHasPrimEqualCond(pJoin, pJoin->node.pConditions, &errCond); + if (primCondGot) { return TSDB_CODE_SUCCESS; } if (errCond) { @@ -1448,6 +1468,22 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin if (IS_WINDOW_JOIN(pJoin->subType) || IS_ASOF_JOIN(pJoin->subType)) { return TSDB_CODE_SUCCESS; } + } + + if (pJoin->leftNoOrderedSubQuery || pJoin->rightNoOrderedSubQuery || !primCondGot) { + pJoin->noPrimKeyEqCond = true; + int32_t code = pdcJoinSplitConstPrimEqCond(pCxt, pJoin, ppCond); + if (code || (pJoin->pPrimKeyEqCond)) { + return code; + } + + if (IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && + NULL != pJoin->node.pConditions) { + code = pdcJoinSplitConstPrimEqCond(pCxt, pJoin, &pJoin->node.pConditions); + if (code || pJoin->pPrimKeyEqCond) { + return code; + } + } return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_EXPECTED_TS_EQUAL); } @@ -1813,6 +1849,7 @@ static int32_t pdcRewriteTypeBasedOnJoinRes(SOptimizeContext* pCxt, SJoinLogicNo return TSDB_CODE_SUCCESS; } + static int32_t pdcDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) { return TSDB_CODE_SUCCESS; @@ -1870,7 +1907,7 @@ static int32_t pdcDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pFullOnCond && !IS_WINDOW_JOIN(pJoin->subType) && - NULL == pJoin->addPrimEqCond) { + NULL == pJoin->addPrimEqCond && NULL == pJoin->pPrimKeyEqCond) { code = pdcJoinSplitPrimEqCond(pCxt, pJoin); } @@ -1993,7 +2030,7 @@ static int32_t partitionAggCond(SAggLogicNode* pAgg, SNode** ppAggFunCond, SNode } static int32_t pushCondToAggCond(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode** pAggFuncCond) { - return pdcMergeConds(&pAgg->node.pConditions, pAggFuncCond); + return nodesMergeNode(&pAgg->node.pConditions, pAggFuncCond); } typedef struct SRewriteAggGroupKeyCondContext { @@ -2619,7 +2656,9 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL bool res = false; SOperatorNode* pOp = (SOperatorNode*)pJoin->pPrimKeyEqCond; - if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || QUERY_NODE_COLUMN != nodeType(pOp->pRight)) { + + if ((QUERY_NODE_COLUMN != nodeType(pOp->pLeft) && QUERY_NODE_VALUE != nodeType(pOp->pLeft)) || + (QUERY_NODE_COLUMN != nodeType(pOp->pRight) && QUERY_NODE_VALUE != nodeType(pOp->pRight))) { return TSDB_CODE_PLAN_INTERNAL_ERROR; } @@ -2629,11 +2668,13 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL if (TSDB_CODE_SUCCESS != code) { return code; } - if (NULL != - tSimpleHashGet(pTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) { + + char* opLeftTable = (QUERY_NODE_COLUMN == nodeType(pOp->pLeft)) ? ((SColumnNode*)pOp->pLeft)->tableAlias : ((SValueNode*)pOp->pLeft)->node.srcTable; + char* opRightTable = (QUERY_NODE_COLUMN == nodeType(pOp->pRight)) ? ((SColumnNode*)pOp->pRight)->tableAlias : ((SValueNode*)pOp->pRight)->node.srcTable; + + if (NULL != tSimpleHashGet(pTables, opLeftTable, strlen(opLeftTable))) { pOrderByNode = pOp->pLeft; - } else if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pRight)->tableAlias, - strlen(((SColumnNode*)pOp->pRight)->tableAlias))) { + } else if (NULL != tSimpleHashGet(pTables, opRightTable, strlen(opRightTable))) { pOrderByNode = pOp->pRight; } @@ -2686,7 +2727,6 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL } *pChildPos = (SNode*)pSort; pSort->node.pParent = (SLogicNode*)pJoin; - ; _return: diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index e12ec77bff..11cb94683b 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -375,7 +375,7 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) { SSetSlotIdCxt* pCxt = (SSetSlotIdCxt*)pContext; char* name = NULL; int32_t len = 0; - pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 16); + pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 64); if (TSDB_CODE_SUCCESS != pCxt->errCode) { return DEAL_RES_ERROR; } @@ -386,7 +386,10 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) { if (!pIndex) { pIndex = taosHashGet(pCxt->pRightProdIdxHash, name, strlen(name)); } - } else { + } + + if (NULL == pIndex) { + name[len] = 0; pIndex = taosHashGet(pCxt->pLeftHash, name, len); if (NULL == pIndex) { pIndex = taosHashGet(pCxt->pRightHash, name, len); @@ -924,7 +927,7 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI } static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_t leftBlkId, int16_t rightBlkId, - SSortMergeJoinPhysiNode* pJoin) { + SSortMergeJoinPhysiNode* pJoin, SJoinLogicNode* pJoinLogicNode) { int32_t code = 0; if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) { SOperatorNode* pOp = (SOperatorNode*)pEqCond; @@ -947,6 +950,16 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ } break; } + case QUERY_NODE_VALUE: { + if (pJoinLogicNode && pJoinLogicNode->leftConstPrimGot) { + pJoin->leftPrimExpr = NULL; + code = nodesCloneNode(pOp->pLeft, &pJoin->leftPrimExpr); + break; + } + + planError("value node got in prim eq left cond, rightType:%d", pOp->pRight ? nodeType(pOp->pRight) : 0); + return TSDB_CODE_PLAN_INTERNAL_ERROR; + } case QUERY_NODE_FUNCTION: { SFunctionNode* pFunc = (SFunctionNode*)pOp->pLeft; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { @@ -995,6 +1008,16 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ } break; } + case QUERY_NODE_VALUE: { + if (pJoinLogicNode && pJoinLogicNode->rightConstPrimGot) { + pJoin->rightPrimExpr = NULL; + code = nodesCloneNode(pOp->pRight, &pJoin->rightPrimExpr); + break; + } + + planError("value node got in prim eq right cond, leftType:%d", pOp->pLeft ? nodeType(pOp->pLeft) : 0); + return TSDB_CODE_PLAN_INTERNAL_ERROR; + } case QUERY_NODE_FUNCTION: { SFunctionNode* pFunc = (SFunctionNode*)pOp->pRight; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { @@ -1034,6 +1057,37 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ return code; } +static int32_t removePrimColFromJoinTargets(SNodeList* pTargets, SValueNode* pPrimExpr, SColumnNode** ppRemoved) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pNode = NULL; + FOREACH(pNode, pTargets) { + SColumnNode* pCol = (SColumnNode*)pNode; + if (0 == strcmp(pCol->tableAlias, pPrimExpr->node.srcTable) && 0 == strcmp(pCol->colName, pPrimExpr->node.aliasName)) { + code = nodesCloneNode(pNode, (SNode**)ppRemoved); + ERASE_NODE(pTargets); + break; + } + } + + return code; +} + +static int32_t appendPrimColToJoinTargets(SSortMergeJoinPhysiNode* pJoin, SColumnNode** ppTarget, STargetNode* primExpr, int16_t blkId) { + SColumnNode* pCol = *ppTarget; + if (TSDB_DATA_TYPE_TIMESTAMP != pCol->node.resType.type) { + planError("primary key output type is not ts, type:%d", pCol->node.resType.type); + return TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS; + } + pCol->dataBlockId = blkId; + pCol->slotId = primExpr->slotId; + int32_t code = nodesListMakeStrictAppend(&pJoin->pTargets, (SNode *)pCol); + if (TSDB_CODE_SUCCESS == code) { + *ppTarget = NULL; + } + + return code; +} + static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) { SSortMergeJoinPhysiNode* pJoin = @@ -1068,7 +1122,7 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi &pJoin->pPrimKeyCond); if (TSDB_CODE_SUCCESS == code) { code = setMergeJoinPrimColEqCond(pJoin->pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, - pRightDesc->dataBlockId, pJoin); + pRightDesc->dataBlockId, pJoin, pJoinLogicNode); } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) { code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc); @@ -1084,7 +1138,7 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi &pPrimKeyCond); if (TSDB_CODE_SUCCESS == code) { code = setMergeJoinPrimColEqCond(pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, - pJoin); + pJoin, NULL); } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) { code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc); @@ -1095,11 +1149,32 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi nodesDestroyNode(pPrimKeyCond); } + SValueNode* pLeftPrimExpr = NULL, *pRightPrimExpr = NULL; + SColumnNode* pLeftTarget = NULL, *pRightTarget = NULL; + if (TSDB_CODE_SUCCESS == code && pJoinLogicNode->leftConstPrimGot && pJoin->leftPrimExpr + && QUERY_NODE_VALUE == nodeType(((STargetNode*)pJoin->leftPrimExpr)->pExpr)) { + pLeftPrimExpr = (SValueNode*)((STargetNode*)pJoin->leftPrimExpr)->pExpr; + code = removePrimColFromJoinTargets(pJoinLogicNode->node.pTargets, pLeftPrimExpr, &pLeftTarget); + } + + if (TSDB_CODE_SUCCESS == code && pJoinLogicNode->rightConstPrimGot && pJoin->rightPrimExpr + && QUERY_NODE_VALUE == nodeType(((STargetNode*)pJoin->rightPrimExpr)->pExpr)) { + pRightPrimExpr = (SValueNode*)((STargetNode*)pJoin->rightPrimExpr)->pExpr; + code = removePrimColFromJoinTargets(pJoinLogicNode->node.pTargets, pRightPrimExpr, &pRightTarget); + } + if (TSDB_CODE_SUCCESS == code) { code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets); } + if (TSDB_CODE_SUCCESS == code && pLeftPrimExpr && pLeftTarget) { + code = appendPrimColToJoinTargets(pJoin, &pLeftTarget, (STargetNode*)pJoin->leftPrimExpr, pLeftDesc->dataBlockId); + } + if (TSDB_CODE_SUCCESS == code && pRightPrimExpr && pRightTarget) { + code = appendPrimColToJoinTargets(pJoin, &pRightTarget, (STargetNode*)pJoin->rightPrimExpr, pRightDesc->dataBlockId); + } + if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pFullOnCond) { code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pJoinLogicNode->pFullOnCond, &pJoin->pFullOnCond); @@ -1151,6 +1226,8 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi *pPhyNode = (SPhysiNode*)pJoin; } else { nodesDestroyNode((SNode*)pJoin); + nodesDestroyNode((SNode*)pLeftTarget); + nodesDestroyNode((SNode*)pRightTarget); } return code; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 9bab697772..7dd3a8e9e3 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1133,29 +1133,7 @@ static uint8_t sclGetOpValueNodeTsPrecision(SNode *pLeft, SNode *pRight) { return 0; } -int32_t sclConvertOpValueNodeTs(SOperatorNode *node) { - if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) { - if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) { - SCL_ERR_RET( - sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode *)node->pLeft)); - } - } else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) { - if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) { - if (SCL_IS_VAR_VALUE_NODE(node->pRight)) { - SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), - (SValueNode *)node->pRight)); - } else if (QUERY_NODE_NODE_LIST == node->pRight->type) { - SNode *pNode; - FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) { - if (SCL_IS_VAR_VALUE_NODE(pNode)) { - SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode)); - } - } - } - } - } - return TSDB_CODE_SUCCESS; -} + int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node) { if (NULL == node->pCase) { @@ -1344,7 +1322,7 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) { EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)*pNode; - ctx->code = sclConvertOpValueNodeTs(node); + ctx->code = scalarConvertOpValueNodeTs(node); if (ctx->code) { return DEAL_RES_ERROR; } @@ -1807,6 +1785,31 @@ static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) { return TSDB_CODE_SUCCESS; } +int32_t scalarConvertOpValueNodeTs(SOperatorNode *node) { + if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) { + if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) { + SCL_ERR_RET( + sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode *)node->pLeft)); + } + } else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) { + if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) { + if (SCL_IS_VAR_VALUE_NODE(node->pRight)) { + SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), + (SValueNode *)node->pRight)); + } else if (QUERY_NODE_NODE_LIST == node->pRight->type) { + SNode *pNode; + FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) { + if (SCL_IS_VAR_VALUE_NODE(pNode)) { + SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode)); + } + } + } + } + } + return TSDB_CODE_SUCCESS; +} + + int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, false, pRes); } int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, true, pRes); } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index cbc7f4d1be..84d2416af2 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -757,9 +757,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TRUE_FOR_NEGATIVE, "True_for duration c TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TRUE_FOR_UNIT, "Cannot use 'year' or 'month' as true_for duration") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_FUNCTION, "Invalid cols function") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_SELECTFUNC, "cols function's first param must be a select function that output a single row") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MULITI_COLS_FUNC, "Improper use of cols function with multiple output columns") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_COLS_ALIAS, "Invalid using alias for cols function") - +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_ALIAS, "Invalid using alias for cols function") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS, "Join primary key col must be timestmap type") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") //planner diff --git a/tests/army/query/joinConst/full_outer.today.csv b/tests/army/query/joinConst/full_outer.today.csv new file mode 100644 index 0000000000..74bb393871 --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today.csv @@ -0,0 +1,763 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a full join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a full join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a full join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a full join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a full join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a full join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/full_outer.today.in b/tests/army/query/joinConst/full_outer.today.in new file mode 100644 index 0000000000..3a151cbcf2 --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a full join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a full join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a full join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/full_outer.today_.csv b/tests/army/query/joinConst/full_outer.today_.csv new file mode 100644 index 0000000000..35e15f4dbd --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today_.csv @@ -0,0 +1,763 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a full join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a full join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a full join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a full join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a full join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a full join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/inner.constts.csv b/tests/army/query/joinConst/inner.constts.csv new file mode 100644 index 0000000000..717f20b460 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" where tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" where tb.ts>timestamp "__today__ 00:00:00.000"; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" where tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" where tb.ts>timestamp "__today__ 00:00:00.000"; + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" ; + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.constts.in b/tests/army/query/joinConst/inner.constts.in new file mode 100644 index 0000000000..008630a119 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts.in @@ -0,0 +1,153 @@ +use test; +select * from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select timestamp __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select timestamp __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select timestamp __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ where tb.ts=timestamp __today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ where tb.ts>timestamp __today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ where tb.ts=timestamp __today__ order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ where tb.ts>timestamp __today__; + + + +select * from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select timestamp __today__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select timestamp __today__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ ; + +select * from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select timestamp __today__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select timestamp __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ ; + + + diff --git a/tests/army/query/joinConst/inner.constts2.csv b/tests/army/query/joinConst/inner.constts2.csv new file mode 100644 index 0000000000..36b3fa310e --- /dev/null +++ b/tests/army/query/joinConst/inner.constts2.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" where tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" where tb.ts>timestamp "__tomorrow__ 00:00:00.000"; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" where tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" where tb.ts>timestamp "__tomorrow__ 00:00:00.000"; + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" ; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.constts3.csv b/tests/army/query/joinConst/inner.constts3.csv new file mode 100644 index 0000000000..7016d37580 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts3.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s where tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s where tb.ts>timestamp "__today__ 00:00:00.000" + 1s; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s where tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s where tb.ts>timestamp "__today__ 00:00:00.000" + 1s; + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s ; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s ; + diff --git a/tests/army/query/joinConst/inner.now.csv b/tests/army/query/joinConst/inner.now.csv new file mode 100644 index 0000000000..a682ed51ef --- /dev/null +++ b/tests/army/query/joinConst/inner.now.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + +taos> select * from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + diff --git a/tests/army/query/joinConst/inner.now.in b/tests/army/query/joinConst/inner.now.in new file mode 100644 index 0000000000..6d1f72c4a4 --- /dev/null +++ b/tests/army/query/joinConst/inner.now.in @@ -0,0 +1,143 @@ +use test; +select * from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; + + + +select * from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + +select * from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + + + diff --git a/tests/army/query/joinConst/inner.now_.csv b/tests/army/query/joinConst/inner.now_.csv new file mode 100644 index 0000000000..b5c3aafdd3 --- /dev/null +++ b/tests/army/query/joinConst/inner.now_.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + +taos> select * from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + diff --git a/tests/army/query/joinConst/inner.today.csv b/tests/army/query/joinConst/inner.today.csv new file mode 100644 index 0000000000..b836987997 --- /dev/null +++ b/tests/army/query/joinConst/inner.today.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/inner.today.in b/tests/army/query/joinConst/inner.today.in new file mode 100644 index 0000000000..fcd0bee97d --- /dev/null +++ b/tests/army/query/joinConst/inner.today.in @@ -0,0 +1,153 @@ +use test; +select * from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + + +select * from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + +select * from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + + + diff --git a/tests/army/query/joinConst/inner.today_.csv b/tests/army/query/joinConst/inner.today_.csv new file mode 100644 index 0000000000..67f23560c8 --- /dev/null +++ b/tests/army/query/joinConst/inner.today_.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + +taos> select * from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + diff --git a/tests/army/query/joinConst/inner.today_ts.csv b/tests/army/query/joinConst/inner.today_ts.csv new file mode 100644 index 0000000000..097e398e17 --- /dev/null +++ b/tests/army/query/joinConst/inner.today_ts.csv @@ -0,0 +1,811 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.*, b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.tomorrow_ts.csv b/tests/army/query/joinConst/inner.tomorrow_ts.csv new file mode 100644 index 0000000000..8987ed2577 --- /dev/null +++ b/tests/army/query/joinConst/inner.tomorrow_ts.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/left_anti.today.csv b/tests/army/query/joinConst/left_anti.today.csv new file mode 100644 index 0000000000..25d63dba19 --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today.csv @@ -0,0 +1,365 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left anti join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left anti join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left anti join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left anti join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.ts1,a.ts from a1 a left anti join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_anti.today.in b/tests/army/query/joinConst/left_anti.today.in new file mode 100644 index 0000000000..5fa57a29db --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left anti join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left anti join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left anti join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_anti.today_.csv b/tests/army/query/joinConst/left_anti.today_.csv new file mode 100644 index 0000000000..e8595eeb7f --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today_.csv @@ -0,0 +1,365 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left anti join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left anti join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left anti join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left anti join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.ts1,a.ts from a1 a left anti join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/left_outer.now.csv b/tests/army/query/joinConst/left_outer.now.csv new file mode 100644 index 0000000000..de72e37014 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now.csv @@ -0,0 +1,490 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select now as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a left join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 201 | 2 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.g from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.c from (select now as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts,a.* from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.*,b.ts from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts | +================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | + NULL | NULL | NULL | __today__ 00:00:01.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.ts,b.f from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | +======================================== + __today__ 00:00:00.000 | 301 | + __today__ 00:00:01.000 | 302 | + __tomorrow__ 00:00:00.000 | 303 | + __tomorrow__ 00:00:02.000 | 304 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts, a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | NULL | NULL | NULL | + __today__ 00:00:01.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | NULL | NULL | NULL | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.g from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select tb.val,tb.tg1,ta.* from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + val | tg1 | ts | val | tg1 | +================================================================================== + 404 | 1 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + val | tg2 | ts | val | tg2 | +================================================================================== + 304 | 1 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + diff --git a/tests/army/query/joinConst/left_outer.now.in b/tests/army/query/joinConst/left_outer.now.in new file mode 100644 index 0000000000..38279c0403 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now.in @@ -0,0 +1,67 @@ +use test; +select * from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select a.* from (select __const__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.g from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts,a.* from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select a.*,b.ts from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts,b.f from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts, a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.g from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select tb.val,tb.tg1,ta.* from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; + + diff --git a/tests/army/query/joinConst/left_outer.now_.csv b/tests/army/query/joinConst/left_outer.now_.csv new file mode 100644 index 0000000000..2d5115143b --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now_.csv @@ -0,0 +1,490 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select now() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a left join (select now() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 201 | 2 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.g from (select now() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.c from (select now() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts,a.* from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.*,b.ts from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts | +================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | + NULL | NULL | NULL | __today__ 00:00:01.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.ts,b.f from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | +======================================== + __today__ 00:00:00.000 | 301 | + __today__ 00:00:01.000 | 302 | + __tomorrow__ 00:00:00.000 | 303 | + __tomorrow__ 00:00:02.000 | 304 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts, a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | NULL | NULL | NULL | + __today__ 00:00:01.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | NULL | NULL | NULL | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.g from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select tb.val,tb.tg1,ta.* from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + val | tg1 | ts | val | tg1 | +================================================================================== + 404 | 1 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + val | tg2 | ts | val | tg2 | +================================================================================== + 304 | 1 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + diff --git a/tests/army/query/joinConst/left_outer.today.csv b/tests/army/query/joinConst/left_outer.today.csv new file mode 100644 index 0000000000..998fef2b48 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_outer.today.in b/tests/army/query/joinConst/left_outer.today.in new file mode 100644 index 0000000000..193b976a62 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_outer.today_.csv b/tests/army/query/joinConst/left_outer.today_.csv new file mode 100644 index 0000000000..11319d4ca1 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today_.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/left_semi.today.csv b/tests/army/query/joinConst/left_semi.today.csv new file mode 100644 index 0000000000..d11a8fe4df --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today.csv @@ -0,0 +1,455 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select * from a1 a left semi join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.* from a1 a left semi join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.*, b.ts from a1 a left semi join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + +taos> select b.c from a1 a left semi join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left semi join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_semi.today.in b/tests/army/query/joinConst/left_semi.today.in new file mode 100644 index 0000000000..72a4a7867c --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left semi join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left semi join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left semi join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_semi.today_.csv b/tests/army/query/joinConst/left_semi.today_.csv new file mode 100644 index 0000000000..45c9e7c4db --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today_.csv @@ -0,0 +1,455 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select * from a1 a left semi join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.* from a1 a left semi join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.*, b.ts from a1 a left semi join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + +taos> select b.c from a1 a left semi join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left semi join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/right_outer.today.csv b/tests/army/query/joinConst/right_outer.today.csv new file mode 100644 index 0000000000..e44401dc75 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.csv @@ -0,0 +1,638 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a right join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a right join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/right_outer.today.in b/tests/army/query/joinConst/right_outer.today.in new file mode 100644 index 0000000000..62d2b80e53 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a right join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a right join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/right_outer.today_.csv b/tests/army/query/joinConst/right_outer.today_.csv new file mode 100644 index 0000000000..9dbbf595bc --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today_.csv @@ -0,0 +1,638 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a right join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a right join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/test_join_const.py b/tests/army/query/test_join_const.py new file mode 100644 index 0000000000..2e0d698cc3 --- /dev/null +++ b/tests/army/query/test_join_const.py @@ -0,0 +1,191 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from frame import etool +from frame.etool import * +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.common import * + +class TDTestCase(TBase): + updatecfgDict = { + "slowLogScope": "none" + } + + today_ts = "" + tomorrow_ts = "" + + def insert_data(self): + tdLog.printNoPrefix("==========step1:create table") + + tdSql.execute("drop database if exists test") + tdSql.execute("create database test keep 36500") + tdSql.execute("use test") + tdSql.execute("create table sta(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") + tdSql.execute("create table stb(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") + tdSql.query("select today();") + self.today_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.today_date = tdSql.res[0][0].strftime('%Y-%m-%d') + tdSql.query("select today() + 1d;") + self.tomorrow_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.tomorrow_date = tdSql.res[0][0].strftime('%Y-%m-%d') + + tdLog.printNoPrefix("==========step2:insert data") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}', 101, 1011);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}' + 1s, 102, 1012);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}', 103, 1013);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}' + 2s, 104, 1014);") + + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}', 201, 2011);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}' + 1s, 202, 2012);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}', 203, 2013);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}' + 3s, 204, 2014);") + + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}', 301, 3011);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}' + 1s, 302, 3012);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}', 303, 3013);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}' + 2s, 304, 3014);") + + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}', 401, 4011);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}' + 1s, 402, 4012);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}', 403, 4013);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}' + 3s, 404, 4014);") + + def replace_string(self, input_file, output_file, old_str, new_str): + script_dir = os.path.dirname(os.path.abspath(__file__)) + with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w') as f_out: + for line in f_in: + modified_line = line.replace(old_str, new_str) + f_out.write(modified_line) + + def replace_string2(self, input_file, output_file, old_str, new_str): + script_dir = os.path.dirname(os.path.abspath(__file__)) + with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w', newline="\r\n") as f_out: + for line in f_in: + modified_line = line.replace(old_str, new_str) + f_out.write(modified_line) + + def test_today_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + today() test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today_.in.tmp1', '__today__', 'today()') + self.replace_string(f'{testCase}.today_.csv', f'{testCase}.today_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today_.csv.tmp1', f'{testCase}.today_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + today test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today.in.tmp1', '__today__', 'today') + self.replace_string(f'{testCase}.today.csv', f'{testCase}.today.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today.csv.tmp1', f'{testCase}.today.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_now_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + now() test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now_.in.tmp1', '__const__', 'now()') + self.replace_string(f'{testCase}.now_.csv', f'{testCase}.now_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now_.csv.tmp1', f'{testCase}.now_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + now test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now.in.tmp1', '__const__', 'now') + self.replace_string(f'{testCase}.now.csv', f'{testCase}.now.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now.csv.tmp1', f'{testCase}.now.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_constts_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.today_ts} test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts.in.tmp1', '__today__', f'"{self.today_ts}"') + self.replace_string(f'{testCase}.constts.csv', f'{testCase}.constts.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts.csv.tmp1', f'{testCase}.constts.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.tomorrow_ts} test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts2.in.tmp2', '__today__', f'"{self.tomorrow_ts}"') + self.replace_string(f'{testCase}.constts2.csv', f'{testCase}.constts2.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts2.csv.tmp1', f'{testCase}.constts2.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts2.in.tmp2") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts2.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.today_ts} + 1s test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts3.in.tmp1', '__today__', f'"{self.today_ts}" + 1s') + self.replace_string(f'{testCase}.constts3.csv', f'{testCase}.constts3.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts3.csv.tmp1', f'{testCase}.constts3.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts3.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts3.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + + def test_nocheck_case(self): + tdLog.printNoPrefix(f"==========step:nocheck test") + tdSql.execute("select * from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select * from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;") + tdSql.execute("select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;") + tdSql.execute("select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;") + tdSql.execute("select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;") + tdSql.execute("select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;") + tdSql.execute("select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;") + tdSql.execute("select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;") + tdSql.execute("select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;") + + def test_abnormal_case(self): + tdLog.printNoPrefix(f"==========step:abnormal case test") + tdSql.error(f"select * from a1 a join (select '{self.today_ts}' as ts from b1) b on a.ts = b.ts;") + tdSql.error(f"select * from a1 a join (select '{self.today_ts}' + 1s as ts from b1) b on a.ts = b.ts;") + tdSql.error(f"select * from a1 a left asof join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.error(f"select * from a1 a left window join (select now as ts1, ts, f, g, 'a' c from b1) b window_offset(-1s, 1s);") + + def run(self): + tdLog.debug(f"start to excute {__file__}") + + self.insert_data() + + self.test_today_case("inner") + self.test_now_case("inner") + self.test_constts_case("inner") + + self.test_today_case("left_outer") + self.test_now_case("left_outer") + self.test_today_case("right_outer") + + self.test_today_case("full_outer") + self.test_today_case("left_semi") + self.test_today_case("left_anti") + + self.test_abnormal_case() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase())