diff --git a/tests/army/query/joinConst/right_outer.today.csv b/tests/army/query/joinConst/right_outer.today.csv index 998fef2b48..e44401dc75 100644 --- a/tests/army/query/joinConst/right_outer.today.csv +++ b/tests/army/query/joinConst/right_outer.today.csv @@ -2,139 +2,103 @@ 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; +taos> select * from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ts | f | g | 'a' | ================================================================================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | - __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; +taos> select * from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; ts | f | g | ts1 | f | g | 'a' | ================================================================================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | - __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; +taos> select a.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | - __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; +taos> select b.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | - 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; +taos> select b.* from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; ts1 | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | - 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; +taos> select a.*, b.ts from a1 a right join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; ts | f | g | ts | ================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | - __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; +taos> select b.c from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; c | ====== a | a | a | a | - 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; +taos> select b.ts from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | - 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; +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | - __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; +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | - __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; +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | - 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; +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; c | ====== a | a | a | a | - 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; +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts | f | g | ts1 | ts | f | g | c | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -142,7 +106,7 @@ taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1 __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; +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -150,7 +114,7 @@ taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from __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; +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts1 | ts | f | g | c | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -158,18 +122,15 @@ taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from __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; +taos> select b.ts1,a.ts from a1 a right join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; ts1 | ts | ==================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | - 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; +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -177,7 +138,7 @@ taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) __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; +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -185,7 +146,7 @@ taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1 __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; +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -193,7 +154,7 @@ taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1 __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; +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; c | ====== a | @@ -201,7 +162,7 @@ taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from 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; +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | @@ -209,95 +170,79 @@ taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from __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; +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __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. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | -taos> select a.* from a1 a left join (select today 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 right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - __today__ 00:00:01.000 | 102 | 1012 | - __tomorrow__ 00:00:00.000 | 103 | 1013 | - __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | -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; +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | + __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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; c | ====== a | - NU. | - NU. | - NU. | + 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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - NULL | - NULL | - NULL | + __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.ts = a.ts and a.ts = b.ts1; +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __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. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | -taos> select a.* from a1 a left join (select today 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 right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - __today__ 00:00:01.000 | 102 | 1012 | - __tomorrow__ 00:00:00.000 | 103 | 1013 | - __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | -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; +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | + __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 b.ts = a.ts and a.ts = b.ts1; +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; c | ====== a | - NU. | - NU. | - NU. | + 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 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; +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | @@ -305,15 +250,7 @@ taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left joi __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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | @@ -321,52 +258,58 @@ taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) __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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - NULL | - NULL | - NULL | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | -taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left 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 today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== - NULL | - NULL | - NULL | - NULL | + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta 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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; ts | val | tg1 | ts | val | tg1 | ============================================================================================================ - __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta 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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | - __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta 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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | @@ -378,111 +321,159 @@ taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where __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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | -taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select * from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | 'a' | ts | f | g | ================================================================================================================== __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +taos> select * from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; ts1 | f | g | 'a' | ts | f | g | ================================================================================================================== __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select a.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select b.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | -taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; ts1 | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | -taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; c | ====== a | a | a | a | + NU. | + NU. | + NU. | -taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | + NULL | + NULL | -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; c | ====== a | a | a | a | + NU. | + NU. | + NU. | -taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | + NULL | + NULL | -taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | @@ -490,7 +481,7 @@ taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 __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; +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -498,7 +489,7 @@ taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a __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; +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -506,7 +497,7 @@ taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join 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; +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; c | ====== a | @@ -514,7 +505,7 @@ taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join 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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | @@ -522,98 +513,116 @@ taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left joi __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; +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | - __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 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - NULL | NULL | NULL | - NULL | NULL | NULL | - NULL | NULL | NULL | + __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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; c | ====== a | - a | - a | - a | + NU. | + NU. | + NU. | -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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - __today__ 00:00:01.000 | - __tomorrow__ 00:00:00.000 | - __tomorrow__ 00:00:02.000 | + NULL | + NULL | + NULL | -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; +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | - __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 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - NULL | NULL | NULL | - NULL | NULL | NULL | - NULL | NULL | NULL | + __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 b.ts = a.ts and a.ts = b.ts1; +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; c | ====== a | - a | - a | - a | + NU. | + NU. | + NU. | -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; +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | - __today__ 00:00:01.000 | - __tomorrow__ 00:00:00.000 | - __tomorrow__ 00:00:02.000 | + NULL | + NULL | + NULL | -taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb 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; +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; ts | val | tg1 | ts | val | tg1 | ============================================================================================================ - __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb 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; +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | - __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | -taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb 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;; +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | @@ -625,17 +634,5 @@ taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 p __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; +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; diff --git a/tests/army/query/joinConst/right_outer.today.in b/tests/army/query/joinConst/right_outer.today.in index eb7ea36d91..62d2b80e53 100644 --- a/tests/army/query/joinConst/right_outer.today.in +++ b/tests/army/query/joinConst/right_outer.today.in @@ -72,7 +72,7 @@ select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; -select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; diff --git a/tests/army/query/joinConst/right_outer.today_.csv b/tests/army/query/joinConst/right_outer.today_.csv index 11319d4ca1..9dbbf595bc 100644 --- a/tests/army/query/joinConst/right_outer.today_.csv +++ b/tests/army/query/joinConst/right_outer.today_.csv @@ -2,139 +2,103 @@ 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; +taos> select * from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ts | f | g | 'a' | ================================================================================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | - __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; +taos> select * from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; ts | f | g | ts1 | f | g | 'a' | ================================================================================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | - __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; +taos> select a.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | - __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; +taos> select b.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | - 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; +taos> select b.* from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; ts1 | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | - 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; +taos> select a.*, b.ts from a1 a right join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; ts | f | g | ts | ================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | - __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; +taos> select b.c from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; c | ====== a | a | a | a | - 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; +taos> select b.ts from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | - 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; +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | - __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; +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | - __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; +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | - 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; +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; c | ====== a | a | a | a | - 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; +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts | f | g | ts1 | ts | f | g | c | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -142,7 +106,7 @@ taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' c from __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; +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -150,7 +114,7 @@ taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c fro __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; +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; ts1 | ts | f | g | c | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -158,18 +122,15 @@ taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c fro __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; +taos> select b.ts1,a.ts from a1 a right join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; ts1 | ts | ==================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | - 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; +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -177,7 +138,7 @@ taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1 __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; +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -185,7 +146,7 @@ taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from __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; +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -193,7 +154,7 @@ taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from __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; +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; c | ====== a | @@ -201,7 +162,7 @@ taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c fro 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; +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | @@ -209,95 +170,79 @@ taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c fr __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; +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __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. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | -taos> select a.* from a1 a left join (select today() 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 right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - __today__ 00:00:01.000 | 102 | 1012 | - __tomorrow__ 00:00:00.000 | 103 | 1013 | - __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | -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; +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | + __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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; c | ====== a | - NU. | - NU. | - NU. | + 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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - NULL | - NULL | - NULL | + __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.ts = a.ts and a.ts = b.ts1; +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ts1 | ts | f | g | 'a' | ============================================================================================================================================ __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __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. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | -taos> select a.* from a1 a left join (select today() 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 right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - __today__ 00:00:01.000 | 102 | 1012 | - __tomorrow__ 00:00:00.000 | 103 | 1013 | - __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | -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; +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | - NULL | NULL | NULL | NULL | NU. | + __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 b.ts = a.ts and a.ts = b.ts1; +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; c | ====== a | - NU. | - NU. | - NU. | + 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 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; +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | @@ -305,15 +250,7 @@ taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left j __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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | @@ -321,52 +258,58 @@ taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by __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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - NULL | - NULL | - NULL | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | -taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left 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 today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; ts | ========================== - NULL | - NULL | - NULL | - NULL | + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta 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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; ts | val | tg1 | ts | val | tg1 | ============================================================================================================ - __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta 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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | - __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | -taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta 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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | @@ -378,111 +321,159 @@ taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where __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; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | -taos> select * from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select * from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | 'a' | ts | f | g | ================================================================================================================== __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select * from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +taos> select * from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; ts1 | f | g | 'a' | ts | f | g | ================================================================================================================== __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | -taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; ts1 | f | g | 'a' | ============================================================ __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | -taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; c | ====== a | a | a | a | + NU. | + NU. | + NU. | -taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | + NULL | + NULL | -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; c | ====== a | a | a | a | + NU. | + NU. | + NU. | -taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; ts1 | ========================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | + NULL | + NULL | -taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | @@ -490,7 +481,7 @@ taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a __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; +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | @@ -498,7 +489,7 @@ taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join __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; +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | @@ -506,7 +497,7 @@ taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join __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; +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; c | ====== a | @@ -514,7 +505,7 @@ taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left jo 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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | @@ -522,98 +513,116 @@ taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left j __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; +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | - __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 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - NULL | NULL | NULL | - NULL | NULL | NULL | - NULL | NULL | NULL | + __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 b.ts1 = a.ts and a.ts = b.ts; +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; c | ====== a | - a | - a | - a | + NU. | + NU. | + NU. | -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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; ts | ========================== __today__ 00:00:00.000 | - __today__ 00:00:01.000 | - __tomorrow__ 00:00:00.000 | - __tomorrow__ 00:00:02.000 | + NULL | + NULL | + NULL | -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; +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ts | f | g | ============================================================================================================================================ __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | - __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 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | -taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts | f | g | ====================================================== __today__ 00:00:00.000 | 101 | 1011 | - NULL | NULL | NULL | - NULL | NULL | NULL | - NULL | NULL | NULL | + __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 b.ts = a.ts and a.ts = b.ts1; +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts1 | ts | f | g | 'a' | ====================================================================================== __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | - __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | - __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | -taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; c | ====== a | - a | - a | - a | + NU. | + NU. | + NU. | -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; +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; ts | ========================== __today__ 00:00:00.000 | - __today__ 00:00:01.000 | - __tomorrow__ 00:00:00.000 | - __tomorrow__ 00:00:02.000 | + NULL | + NULL | + NULL | -taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb 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; +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; ts | val | tg1 | ts | val | tg1 | ============================================================================================================ - __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb 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; +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ - __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | - __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | -taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb 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;; +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; ts | val | tg2 | ts | val | tg2 | ============================================================================================================ __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | @@ -625,17 +634,5 @@ taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 __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(); +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); diff --git a/tests/army/query/test_join_const.py b/tests/army/query/test_join_const.py index f5ad49d6e1..2e0d698cc3 100644 --- a/tests/army/query/test_join_const.py +++ b/tests/army/query/test_join_const.py @@ -176,7 +176,7 @@ class TDTestCase(TBase): self.test_today_case("left_outer") self.test_now_case("left_outer") - #self.test_today_case("right_outer") + self.test_today_case("right_outer") self.test_today_case("full_outer") self.test_today_case("left_semi")