homework-jianmu/tests/script/tsim/join/left_semi_join.sim

149 lines
3.1 KiB
Plaintext

sql connect
sql use test0;
sql select a.ts, b.ts from sta a left semi join sta b on a.ts = b.ts and a.ts < '2023-11-17 16:29:02' order by a.ts
if $rows != 3 then
return -1
endi
if $data00 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data20 != @23-11-17 16:29:01.000@ then
return -1
endi
if $data21 != @23-11-17 16:29:01.000@ then
return -1
endi
sql select a.col1, b.col1 from sta a left semi join sta b on a.ts = b.ts where a.ts < '2023-11-17 16:29:02' and b.ts < '2023-11-17 16:29:01' order by a.col1;
if $rows != 2 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
sql select a.col1, b.col1 from sta a left semi join sta b on a.ts = b.ts;
if $rows != 8 then
return -1
endi
sql select a.col1, b.col1 from tba1 a left semi join tba2 b on a.ts = b.ts order by a.col1;
if $rows != 2 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data10 != 4 then
return -1
endi
if $data11 != 5 then
return -1
endi
sql select a.col1, b.col1 from tba2 a left semi join tba1 b on a.ts = b.ts order by a.col1;
if $rows != 2 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != 5 then
return -1
endi
if $data11 != 4 then
return -1
endi
sql select a.ts, b.ts from tba1 a left semi join tba2 b on a.ts = b.ts order by a.ts desc;
if $rows != 2 then
return -1
endi
if $data00 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:00.000@ then
return -1
endi
sql select a.ts, b.ts from sta a left semi join sta b on a.ts = b.ts order by a.ts desc;
if $rows != 8 then
return -1
endi
if $data00 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:05.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:04.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:04.000@ then
return -1
endi
sql select a.ts, b.ts from tba1 a left semi join tba2 b on a.ts = b.ts order by b.ts desc;
if $rows != 2 then
return -1
endi
if $data00 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:00.000@ then
return -1
endi
sql select a.ts, b.ts from tba1 a left semi join tba2 b on a.ts = b.ts order by b.ts desc, a.ts;
if $rows != 2 then
return -1
endi
if $data00 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data01 != @23-11-17 16:29:03.000@ then
return -1
endi
if $data10 != @23-11-17 16:29:00.000@ then
return -1
endi
if $data11 != @23-11-17 16:29:00.000@ then
return -1
endi
sql_error select a.ts, b.ts from sta a left semi join sta b jlimit 3 where a.ts > b.ts;
sql_error select a.ts, b.ts from sta a left semi join sta b where a.ts > b.ts;
sql_error select a.ts, b.ts from sta a left semi join sta b on a.ts > 1 where a.ts = b.ts;