From 88fe9fc5845997b3a15f9803761421d553ca786d Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 12 Mar 2025 11:04:54 +0800 Subject: [PATCH] enh: add more cases --- .../query/joinConst/right_outer.today.csv | 641 ++++++++++++++++++ .../army/query/joinConst/right_outer.today.in | 79 +++ .../query/joinConst/right_outer.today_.csv | 641 ++++++++++++++++++ tests/army/query/test_join_const.py | 19 +- 4 files changed, 1371 insertions(+), 9 deletions(-) create mode 100644 tests/army/query/joinConst/right_outer.today.csv create mode 100644 tests/army/query/joinConst/right_outer.today.in create mode 100644 tests/army/query/joinConst/right_outer.today_.csv diff --git a/tests/army/query/joinConst/right_outer.today.csv b/tests/army/query/joinConst/right_outer.today.csv new file mode 100644 index 0000000000..998fef2b48 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/right_outer.today.in b/tests/army/query/joinConst/right_outer.today.in new file mode 100644 index 0000000000..eb7ea36d91 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a right join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a right join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/right_outer.today_.csv b/tests/army/query/joinConst/right_outer.today_.csv new file mode 100644 index 0000000000..11319d4ca1 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today_.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/test_join_const.py b/tests/army/query/test_join_const.py index 37365f2a78..f5ad49d6e1 100644 --- a/tests/army/query/test_join_const.py +++ b/tests/army/query/test_join_const.py @@ -170,18 +170,19 @@ class TDTestCase(TBase): self.insert_data() - #self.test_today_case("inner") - #self.test_now_case("inner") - #self.test_constts_case("inner") + self.test_today_case("inner") + self.test_now_case("inner") + self.test_constts_case("inner") - #self.test_today_case("left_outer") - #self.test_now_case("left_outer") + self.test_today_case("left_outer") + self.test_now_case("left_outer") + #self.test_today_case("right_outer") - #self.test_today_case("full_outer") - #self.test_today_case("left_semi") - #self.test_today_case("left_anti") + self.test_today_case("full_outer") + self.test_today_case("left_semi") + self.test_today_case("left_anti") - #self.test_abnormal_case() + self.test_abnormal_case() tdLog.success(f"{__file__} successfully executed")