From a4ed19b36d1b056bf5e4aa6a4091f26a3447b8b7 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 11 Mar 2025 11:29:49 +0800 Subject: [PATCH] enh: add left join cases --- include/util/taoserror.h | 1 + source/libs/executor/inc/mergejoin.h | 2 + source/libs/planner/src/planOptimizer.c | 17 +- source/libs/planner/src/planPhysiCreater.c | 4 + source/util/src/terror.c | 1 + tests/army/query/joinConst/inner.constts.csv | 969 ++++++++++++++++++ tests/army/query/joinConst/inner.constts.in | 286 +++--- tests/army/query/joinConst/inner.constts2.csv | 969 ++++++++++++++++++ tests/army/query/joinConst/inner.constts3.csv | 969 ++++++++++++++++++ tests/army/query/joinConst/left_outer.now.csv | 490 +++++++++ tests/army/query/joinConst/left_outer.now.in | 67 ++ .../army/query/joinConst/left_outer.now_.csv | 490 +++++++++ tests/army/query/test_join_const.py | 30 +- 13 files changed, 4136 insertions(+), 159 deletions(-) create mode 100644 tests/army/query/joinConst/inner.constts.csv create mode 100644 tests/army/query/joinConst/inner.constts2.csv create mode 100644 tests/army/query/joinConst/inner.constts3.csv create mode 100644 tests/army/query/joinConst/left_outer.now.csv create mode 100644 tests/army/query/joinConst/left_outer.now.in create mode 100644 tests/army/query/joinConst/left_outer.now_.csv diff --git a/include/util/taoserror.h b/include/util/taoserror.h index b3bd774df4..a9fbc79550 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -915,6 +915,7 @@ int32_t taosGetErrSize(); #define TSDB_CODE_PAR_INVALID_COLS_SELECTFUNC TAOS_DEF_ERROR_CODE(0, 0x268A) #define TSDB_CODE_PAR_INVALID_COLS_ALIAS TAOS_DEF_ERROR_CODE(0, 0x268B) #define TSDB_CODE_PAR_VALID_TS_SERIOUS_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x268C) +#define TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS TAOS_DEF_ERROR_CODE(0, 0x268D) #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 a67e31760c..52eb264639 100755 --- a/source/libs/executor/inc/mergejoin.h +++ b/source/libs/executor/inc/mergejoin.h @@ -348,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/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index d16f0dbaf7..d8f6b79413 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2696,11 +2696,9 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL bool res = false; SOperatorNode* pOp = (SOperatorNode*)pJoin->pPrimKeyEqCond; - if (QUERY_NODE_VALUE == nodeType(pOp->pLeft) || QUERY_NODE_VALUE == nodeType(pOp->pRight)) { - return TSDB_CODE_SUCCESS; - } - 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; } @@ -2710,11 +2708,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; } @@ -2767,7 +2767,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 876fc12f8e..af6b15f58f 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1074,6 +1074,10 @@ static int32_t removePrimColFromJoinTargets(SNodeList* pTargets, SValueNode* pPr 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); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 94a6c92a38..3e68e26ab5 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -759,6 +759,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_FUNCTION, "Invalid cols functi 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_PAR_INVALID_COLS_ALIAS, "Invalid using alias for cols function") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_VALID_TS_SERIOUS_REQUIRED, "Valid time series required as input") +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/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 index fcd0bee97d..008630a119 100644 --- a/tests/army/query/joinConst/inner.constts.in +++ b/tests/army/query/joinConst/inner.constts.in @@ -1,153 +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 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 __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 (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 __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 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 __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__ ; +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/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/test_join_const.py b/tests/army/query/test_join_const.py index bb3d988701..046861e132 100644 --- a/tests/army/query/test_join_const.py +++ b/tests/army/query/test_join_const.py @@ -118,18 +118,32 @@ class TDTestCase(TBase): 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}.today_ts.csv") + 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}.constts.in.tmp2', '__today__', f'"{self.tomorrow_ts}"') + 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}.constts.in.tmp2") - self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.tomorrow_ts.csv") + 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;") @@ -146,7 +160,8 @@ class TDTestCase(TBase): def test_abnormal_case(self): tdLog.printNoPrefix(f"==========step:abnormal case test") - tdSql.error("select interp(c1) from test.td32727 range('2020-02-01 00:00:00.000', '2020-02-01 00:00:30.000', -1s) every(2s) fill(prev, 99);") + 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;") def run(self): tdLog.debug(f"start to excute {__file__}") @@ -155,11 +170,12 @@ class TDTestCase(TBase): self.test_today_case("inner") self.test_now_case("inner") - #self.test_constts_case("inner") + self.test_constts_case("inner") self.test_today_case("left_outer") + self.test_now_case("left_outer") - #self.test_abnormal_case() + self.test_abnormal_case() tdLog.success(f"{__file__} successfully executed")