From 364381c6f1f00b6aa5a42513e5db926e11e47d75 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 6 Mar 2025 19:27:09 +0800 Subject: [PATCH] fix: constant join issues --- source/libs/parser/src/parCalcConst.c | 52 +- source/libs/parser/src/parTranslater.c | 25 +- source/libs/planner/src/planOptimizer.c | 6 +- source/libs/planner/src/planPhysiCreater.c | 4 +- .../joinConst/{inner.in => inner.constts.in} | 0 tests/army/query/joinConst/inner.now.csv | 377 ++++ tests/army/query/joinConst/inner.now.in | 143 ++ tests/army/query/joinConst/inner.now_.csv | 377 ++++ tests/army/query/joinConst/inner.today.csv | 1938 ++++++++--------- tests/army/query/joinConst/inner.today.in | 153 ++ tests/army/query/joinConst/inner.today_.csv | 1938 ++++++++--------- tests/army/query/joinConst/inner.today_ts.csv | 811 +++++++ .../query/joinConst/inner.tomorrow_ts.csv | 969 +++++++++ .../army/query/joinConst/left_outer.today.csv | 641 ++++++ .../army/query/joinConst/left_outer.today.in | 79 + .../query/joinConst/left_outer.today_.csv | 641 ++++++ tests/army/query/test_join_const.py | 151 +- 17 files changed, 6294 insertions(+), 2011 deletions(-) rename tests/army/query/joinConst/{inner.in => inner.constts.in} (100%) create mode 100644 tests/army/query/joinConst/inner.now.csv create mode 100644 tests/army/query/joinConst/inner.now.in create mode 100644 tests/army/query/joinConst/inner.now_.csv create mode 100644 tests/army/query/joinConst/inner.today.in create mode 100644 tests/army/query/joinConst/inner.today_ts.csv create mode 100644 tests/army/query/joinConst/inner.tomorrow_ts.csv create mode 100644 tests/army/query/joinConst/left_outer.today.csv create mode 100644 tests/army/query/joinConst/left_outer.today.in create mode 100644 tests/army/query/joinConst/left_outer.today_.csv diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 96a0963516..8295e67dee 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -118,6 +118,39 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SNode** pNode) { return code; } +static EDealRes rewriteCalcConstValue(SNode** pNode, void* pContext) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; + SCalcConstContext* pCtx = (SCalcConstContext*)pContext; + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pNode)) { + return DEAL_RES_CONTINUE; + } else if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { + SOperatorNode* pOp = (SOperatorNode*)*pNode; + if (OP_TYPE_EQUAL == pOp->opType && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pLeft)->resType.type || TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pRight)->resType.type)) { + code = calcConstNode(&pOp->pLeft); + if (TSDB_CODE_SUCCESS == code) { + code = calcConstNode(&pOp->pRight); + } + + goto _end; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = calcConstCondition(pCtx, pNode); + } + +_end: + + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + return DEAL_RES_ERROR; + } + + return DEAL_RES_IGNORE_CHILD; +} + static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -132,6 +165,14 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab if (TSDB_CODE_SUCCESS == code) { code = rewriteConditionForFromTable(pCxt, pJoin->pRight); } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + code = rewriteCondition(pCxt, &pJoin->pOnCond); + } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + nodesRewriteExpr(&pJoin->pOnCond, rewriteCalcConstValue, pCxt); + } + +/* if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { code = nodesCloneNode(pJoin->pOnCond, &pCond); } @@ -142,18 +183,9 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab nodesDestroyNode(pJoin->pOnCond); pJoin->pOnCond = pCond; pCond = NULL; - /* TODO - SValueNode* pVal = (SValueNode*)pJoin->pOnCond; - if (TSDB_DATA_TYPE_BOOL == pVal->node.resType.type) { - if (pVal->datum.b) { - pJoin->condAlwaysTrue = true; - } else { - pJoin->condAlwaysFalse = true; - } - } - */ } nodesDestroyNode(pCond); +*/ // todo empty table break; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 07d674f70c..db020d9dff 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5107,21 +5107,34 @@ int32_t mergeInnerJoinConds(SNode** ppDst, SNode** ppSrc) { while (true) { if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppDst) && ((SLogicConditionNode*)*ppDst)->condType == LOGIC_COND_TYPE_AND) { SLogicConditionNode* pLogic = (SLogicConditionNode*)*ppDst; - code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); - if (TSDB_CODE_SUCCESS == code) { - *ppSrc = NULL; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + SLogicConditionNode* pSrcLogic = (SLogicConditionNode*)*ppSrc; + code = nodesListMakeStrictAppendList(&pLogic->pParameterList, pSrcLogic->pParameterList); + if (TSDB_CODE_SUCCESS == code) { + pSrcLogic->pParameterList = NULL; + nodesDestroyNode(*ppSrc); + *ppSrc = NULL; + } + } else { + code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); + if (TSDB_CODE_SUCCESS == code) { + *ppSrc = NULL; + } } + return code; } - if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { SNode* pTmp = *ppDst; *ppDst = *ppSrc; *ppSrc = pTmp; continue; } - code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &pNew); + if (TSDB_CODE_SUCCESS == code) { + code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &pNew); + } if (TSDB_CODE_SUCCESS == code) { SLogicConditionNode* pLogic = (SLogicConditionNode*)pNew; pLogic->condType = LOGIC_COND_TYPE_AND; @@ -5229,7 +5242,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, bool inJoin) { if (TSDB_CODE_SUCCESS == code) { code = checkJoinTable(pCxt, pJoinTable); } - if (TSDB_CODE_SUCCESS == code && pCurrSmt->pWhere && JOIN_TYPE_INNER == pJoinTable->joinType) { + if (TSDB_CODE_SUCCESS == code && !inJoin && pCurrSmt->pWhere && JOIN_TYPE_INNER == pJoinTable->joinType) { if (pJoinTable->pOnCond) { code = mergeInnerJoinConds(&pJoinTable->pOnCond, &pCurrSmt->pWhere); } else { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 2e23a9987b..d16f0dbaf7 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -946,7 +946,7 @@ static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppInpu SNode* pCond = NULL; WHERE_EACH(pCond, pLogicCond->pParameterList) { SNode* pNew = NULL; - if (pdcJoinIsPrimEqualCond(pJoin, pCond, constAsPrim) && (NULL == *ppPrimEqCond)) { + if (pdcJoinIsPrimEqualCond(pJoin, pCond, constAsPrim) && (NULL == *ppPrimEqCond) && (!constAsPrim || pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { code = nodesCloneNode(pCond, &pNew); if (TSDB_CODE_SUCCESS != code) break; *ppPrimEqCond = pNew; @@ -1446,7 +1446,7 @@ static int32_t pdcJoinSplitConstPrimEqCond(SOptimizeContext* pCxt, SJoinLogicNod if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppCond) && LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*ppCond)->condType) { code = pdcJoinSplitPrimInLogicCond(pJoin, ppCond, &pPrimKeyEqCond, &pJoinOnCond, true); - } else if (pdcJoinIsPrimEqualCond(pJoin, *ppCond, true)) { + } else if (pdcJoinIsPrimEqualCond(pJoin, *ppCond, true) && (pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { pPrimKeyEqCond = *ppCond; pJoinOnCond = NULL; } else { @@ -1512,7 +1512,7 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin if (pJoin->leftNoOrderedSubQuery || pJoin->rightNoOrderedSubQuery || !primCondGot) { pJoin->noPrimKeyEqCond = true; int32_t code = pdcJoinSplitConstPrimEqCond(pCxt, pJoin, ppCond); - if (code || pJoin->pPrimKeyEqCond) { + if (code || (pJoin->pPrimKeyEqCond)) { return code; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 8a7d940789..876fc12f8e 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1057,12 +1057,12 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ return code; } -static int32_t removePrimColFromJoinTargets(SNodeList* pTargets, SValueNode* pLeftPrimExpr, SColumnNode** ppRemoved) { +static int32_t removePrimColFromJoinTargets(SNodeList* pTargets, SValueNode* pPrimExpr, SColumnNode** ppRemoved) { int32_t code = TSDB_CODE_SUCCESS; SNode* pNode = NULL; FOREACH(pNode, pTargets) { SColumnNode* pCol = (SColumnNode*)pNode; - if (0 == strcmp(pCol->tableAlias, pLeftPrimExpr->node.srcTable) && 0 == strcmp(pCol->colName, pLeftPrimExpr->node.aliasName)) { + if (0 == strcmp(pCol->tableAlias, pPrimExpr->node.srcTable) && 0 == strcmp(pCol->colName, pPrimExpr->node.aliasName)) { code = nodesCloneNode(pNode, (SNode**)ppRemoved); ERASE_NODE(pTargets); break; diff --git a/tests/army/query/joinConst/inner.in b/tests/army/query/joinConst/inner.constts.in similarity index 100% rename from tests/army/query/joinConst/inner.in rename to tests/army/query/joinConst/inner.constts.in diff --git a/tests/army/query/joinConst/inner.now.csv b/tests/army/query/joinConst/inner.now.csv new file mode 100644 index 0000000000..a682ed51ef --- /dev/null +++ b/tests/army/query/joinConst/inner.now.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + +taos> select * from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + diff --git a/tests/army/query/joinConst/inner.now.in b/tests/army/query/joinConst/inner.now.in new file mode 100644 index 0000000000..6d1f72c4a4 --- /dev/null +++ b/tests/army/query/joinConst/inner.now.in @@ -0,0 +1,143 @@ +use test; +select * from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; + + + +select * from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + +select * from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + + + diff --git a/tests/army/query/joinConst/inner.now_.csv b/tests/army/query/joinConst/inner.now_.csv new file mode 100644 index 0000000000..b5c3aafdd3 --- /dev/null +++ b/tests/army/query/joinConst/inner.now_.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + +taos> select * from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + diff --git a/tests/army/query/joinConst/inner.today.csv b/tests/army/query/joinConst/inner.today.csv index 16bc5787e2..b836987997 100644 --- a/tests/army/query/joinConst/inner.today.csv +++ b/tests/army/query/joinConst/inner.today.csv @@ -1,969 +1,969 @@ - -taos> use test; -Database changed. - -taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | ts | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; - ts | f | g | ts1 | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; - ts1 | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; - ts | f | g | ts | -================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:01.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:02.000 | - -taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts | f | g | ts1 | ts | f | g | c | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts1 | ts | f | g | c | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; - ts1 | ts | -==================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-04 00:00:03.000 | 204 | 2 | 2025-03-04 00:00:03.000 | 404 | 2 | - -taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; - ts1 | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; - ts1 | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; - -taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | ts | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; - ts | f | g | ts1 | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; - -taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; - ts1 | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; - + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/inner.today.in b/tests/army/query/joinConst/inner.today.in new file mode 100644 index 0000000000..fcd0bee97d --- /dev/null +++ b/tests/army/query/joinConst/inner.today.in @@ -0,0 +1,153 @@ +use test; +select * from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + + +select * from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + +select * from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + + + diff --git a/tests/army/query/joinConst/inner.today_.csv b/tests/army/query/joinConst/inner.today_.csv index 5f613e1b93..67f23560c8 100644 --- a/tests/army/query/joinConst/inner.today_.csv +++ b/tests/army/query/joinConst/inner.today_.csv @@ -1,969 +1,969 @@ - -taos> use test; -Database changed. - -taos> select * from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | ts | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select * from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; - ts | f | g | ts1 | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.* from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; - ts1 | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.*, b.ts from a1 a join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; - ts | f | g | ts | -================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:01.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:02.000 | - -taos> select b.c from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts | f | g | ts1 | ts | f | g | c | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; - ts1 | ts | f | g | c | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.ts1,a.ts from a1 a join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; - ts1 | ts | -==================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-04 00:00:03.000 | 204 | 2 | 2025-03-04 00:00:03.000 | 404 | 2 | - -taos> select * from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select * from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; - ts1 | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; - ts1 | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); - -taos> select * from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | ts | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select * from a1 a , (select today() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; - ts | f | g | ts1 | f | g | 'a' | -================================================================================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:01.000 | 102 | 1012 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-04 00:00:00.000 | 103 | 1013 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-04 00:00:02.000 | 104 | 1014 | 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | ts1 | ts | f | g | 'a' | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1011 | 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 301 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 302 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 303 | 1 | - 2025-03-03 00:00:00.000 | 101 | 1 | 2025-03-03 00:00:00.000 | 304 | 1 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 401 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 402 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 403 | 2 | - 2025-03-03 00:00:00.000 | 201 | 2 | 2025-03-03 00:00:00.000 | 404 | 2 | - -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; - -taos> select * from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select * from (select today() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; - ts1 | f | g | 'a' | ts | f | g | -================================================================================================================== - 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | 'a' | -============================================================ - 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; - ts1 | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - 2025-03-03 00:00:01.000 | 102 | 1012 | - 2025-03-04 00:00:00.000 | 103 | 1013 | - 2025-03-04 00:00:02.000 | 104 | 1014 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:01.000 | 302 | 3012 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | - 2025-03-03 00:00:00.000 | 2025-03-04 00:00:02.000 | 304 | 3014 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - c | -====== - a | - a | - a | - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - 2025-03-03 00:00:01.000 | - 2025-03-04 00:00:00.000 | - 2025-03-04 00:00:02.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - c | -====== - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | ts | f | g | -============================================================================================================================================ - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts | f | g | -====================================================== - 2025-03-03 00:00:00.000 | 101 | 1011 | - -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts1 | ts | f | g | 'a' | -====================================================================================== - 2025-03-03 00:00:00.000 | 2025-03-03 00:00:00.000 | 301 | 3011 | a | - -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - c | -====== - a | - -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; - ts | -========================== - 2025-03-03 00:00:00.000 | - -taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; - ts | val | tg2 | ts | val | tg2 | -============================================================================================================ - 2025-03-03 00:00:00.000 | 301 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 302 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 303 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 304 | 1 | 2025-03-03 00:00:00.000 | 101 | 1 | - 2025-03-03 00:00:00.000 | 401 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 402 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 403 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - 2025-03-03 00:00:00.000 | 404 | 2 | 2025-03-03 00:00:00.000 | 201 | 2 | - -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; - + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + +taos> select * from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + diff --git a/tests/army/query/joinConst/inner.today_ts.csv b/tests/army/query/joinConst/inner.today_ts.csv new file mode 100644 index 0000000000..097e398e17 --- /dev/null +++ b/tests/army/query/joinConst/inner.today_ts.csv @@ -0,0 +1,811 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.*, b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.tomorrow_ts.csv b/tests/army/query/joinConst/inner.tomorrow_ts.csv new file mode 100644 index 0000000000..8987ed2577 --- /dev/null +++ b/tests/army/query/joinConst/inner.tomorrow_ts.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/left_outer.today.csv b/tests/army/query/joinConst/left_outer.today.csv new file mode 100644 index 0000000000..998fef2b48 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_outer.today.in b/tests/army/query/joinConst/left_outer.today.in new file mode 100644 index 0000000000..193b976a62 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_outer.today_.csv b/tests/army/query/joinConst/left_outer.today_.csv new file mode 100644 index 0000000000..11319d4ca1 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today_.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/test_join_const.py b/tests/army/query/test_join_const.py index ab19980c68..bb3d988701 100644 --- a/tests/army/query/test_join_const.py +++ b/tests/army/query/test_join_const.py @@ -24,6 +24,9 @@ class TDTestCase(TBase): "slowLogScope": "none" } + today_ts = "" + tomorrow_ts = "" + def insert_data(self): tdLog.printNoPrefix("==========step1:create table") @@ -33,86 +36,130 @@ class TDTestCase(TBase): tdSql.execute("create table sta(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") tdSql.execute("create table stb(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") tdSql.query("select today();") - today_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.today_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.today_date = tdSql.res[0][0].strftime('%Y-%m-%d') tdSql.query("select today() + 1d;") - tomorrow_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.tomorrow_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.tomorrow_date = tdSql.res[0][0].strftime('%Y-%m-%d') tdLog.printNoPrefix("==========step2:insert data") - tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{today_ts}', 101, 1011);") - tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{today_ts}' + 1s, 102, 1012);") - tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{tomorrow_ts}', 103, 1013);") - tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{tomorrow_ts}' + 2s, 104, 1014);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}', 101, 1011);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}' + 1s, 102, 1012);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}', 103, 1013);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}' + 2s, 104, 1014);") - tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{today_ts}', 201, 2011);") - tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{today_ts}' + 1s, 202, 2012);") - tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{tomorrow_ts}', 203, 2013);") - tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{tomorrow_ts}' + 3s, 204, 2014);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}', 201, 2011);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}' + 1s, 202, 2012);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}', 203, 2013);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}' + 3s, 204, 2014);") - tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{today_ts}', 301, 3011);") - tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{today_ts}' + 1s, 302, 3012);") - tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{tomorrow_ts}', 303, 3013);") - tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{tomorrow_ts}' + 2s, 304, 3014);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}', 301, 3011);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}' + 1s, 302, 3012);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}', 303, 3013);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}' + 2s, 304, 3014);") - tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{today_ts}', 401, 4011);") - tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{today_ts}' + 1s, 402, 4012);") - tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{tomorrow_ts}', 403, 4013);") - tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{tomorrow_ts}' + 3s, 404, 4014);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}', 401, 4011);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}' + 1s, 402, 4012);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}', 403, 4013);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}' + 3s, 404, 4014);") def replace_string(self, input_file, output_file, old_str, new_str): - print("当前工作目录:", os.getcwd()) script_dir = os.path.dirname(os.path.abspath(__file__)) with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w') as f_out: for line in f_in: modified_line = line.replace(old_str, new_str) f_out.write(modified_line) - def test_normal_case(self, testCase): - self.replace_string(f'{testCase}.in', f'{testCase}.in.today_', '__today__', 'today()') + def replace_string2(self, input_file, output_file, old_str, new_str): + script_dir = os.path.dirname(os.path.abspath(__file__)) + with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w', newline="\r\n") as f_out: + for line in f_in: + modified_line = line.replace(old_str, new_str) + f_out.write(modified_line) + + def test_today_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + today() test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today_.in.tmp1', '__today__', 'today()') + self.replace_string(f'{testCase}.today_.csv', f'{testCase}.today_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today_.csv.tmp1', f'{testCase}.today_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') # read sql from .sql file and execute - self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.today_") - self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.csv") + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.csv.tmp2") tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) - self.replace_string(f'{testCase}.in', f'{testCase}.in.today', '__today__', 'today') + tdLog.printNoPrefix(f"==========step:{testCase} + today test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today.in.tmp1', '__today__', 'today') + self.replace_string(f'{testCase}.today.csv', f'{testCase}.today.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today.csv.tmp1', f'{testCase}.today.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') # read sql from .sql file and execute - self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.today") - self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today.csv") + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today.csv.tmp2") tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) -# self.replace_string(f'{testCase}.in', f'{testCase}.in.now_', '__today__', 'now()') -# # read sql from .sql file and execute -# self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.now_") -# self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.csv") -# tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) -# -# self.replace_string(f'{testCase}.in', f'{testCase}.in.now', '__today__', 'now') -# # read sql from .sql file and execute -# self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.now") -# self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now.csv") -# tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) -# -# self.replace_string(f'{testCase}.in', f'{testCase}.in.today_ts', '__today__', f'{today_ts}') -# # read sql from .sql file and execute -# self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.today_ts") -# self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today_ts.csv") -# tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) -# -# self.replace_string(f'{testCase}.in', f'{testCase}.in.tomorrow_ts', '__today__', f'{tomorrow_ts}') -# # read sql from .sql file and execute -# self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.in.tomorrow_ts") -# self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.tomorrow_ts.csv") -# tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + def test_now_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + now() test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now_.in.tmp1', '__const__', 'now()') + self.replace_string(f'{testCase}.now_.csv', f'{testCase}.now_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now_.csv.tmp1', f'{testCase}.now_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + now test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now.in.tmp1', '__const__', 'now') + self.replace_string(f'{testCase}.now.csv', f'{testCase}.now.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now.csv.tmp1', f'{testCase}.now.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_constts_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.today_ts} test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts.in.tmp1', '__today__', f'"{self.today_ts}"') + # 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") + 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}"') + # 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") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_nocheck_case(self): + tdLog.printNoPrefix(f"==========step:nocheck test") + tdSql.execute("select * from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + #tdSql.execute("select * from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + #select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + #select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + #select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + #select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + #select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + #select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + #select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + #select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + #select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; def test_abnormal_case(self): - tdLog.info("test abnormal case.") + 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);") def run(self): tdLog.debug(f"start to excute {__file__}") self.insert_data() - self.test_normal_case("inner") - self.test_abnormal_case() + + self.test_today_case("inner") + self.test_now_case("inner") + #self.test_constts_case("inner") + + self.test_today_case("left_outer") + + #self.test_abnormal_case() tdLog.success(f"{__file__} successfully executed")