TDengine/tests/script/general/parser/slimit1_query.sim
Shuduo Sang d69c5977db
Test/sangshuduo/td 13408 move tests in (#10589)
* restore .gitmodules

* Revert "[TD-13408]<test>: move tests directory out"

This reverts commit 7db7bd9337.

* revert to make tests back

* immigrate file change in stand-alone repo to TDengine

* remove tests repository checkout

Co-authored-by: tangfangzhi <fztang@taosdata.com>
2022-03-07 17:59:24 +08:00

184 lines
2.9 KiB
Text

sleep 100
sql connect
$dbPrefix = slm_alt_tg_db
print ========== slimit1_query.sim
# make sure the data in each table crosses a file block boundary
$rowNum = 300
$ts0 = 1537146000000
$delta = 600000
$db = $dbPrefix
sql use $db
#### group by t2,t1 + slimit
sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 6
if $rows != 3 then
return -1
endi
if $data00 != $rowNum then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 6 then
return -1
endi
if $data10 != $rowNum then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data12 != 7 then
return -1
endi
$res = 2 * $rowNum
if $data20 != $res then
return -1
endi
if $data21 != 2 then
return -1
endi
if $data22 != 8 then
return -1
endi
## desc
sql select count(*) from stb group by t2,t1 order by t2 desc slimit 5 soffset 0
if $rows != 5 then
return -1
endi
$res = 2 * $rowNum
if $data00 != $res then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 8 then
return -1
endi
if $data10 != $rowNum then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data12 != 7 then
return -1
endi
if $data20 != $rowNum then
return -1
endi
if $data21 != 2 then
return -1
endi
if $data22 != 6 then
return -1
endi
if $data30 != $rowNum then
return -1
endi
if $data31 != 1 then
return -1
endi
if $data32 != 5 then
return -1
endi
if $data40 != $rowNum then
return -1
endi
if $data41 != 1 then
return -1
endi
if $data42 != 4 then
return -1
endi
### empty result set
#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 0 soffset 0
#if $rows != 0 then
# return -1
#endi
#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 10
#if $rows != 0 then
# return -1
#endi
#### group by t2 + slimit
sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 0
if $rows != 2 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
if $data10 != $res then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data11 != 1 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 0
if $rows != 2 then
return -1
endi
$res = 4 * $rowNum
if $data00 != $res then
return -1
endi
$res = 3 * $rowNum
if $data10 != $res then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 1 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 1
if $rows != 2 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
$res = 4 * $rowNum
if $data10 != $res then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data11 != 2 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 1
if $rows != 2 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
if $data10 != $res then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data11 != 0 then
return -1
endi