提交 0d94fba0 编写于 作者: S shenglian zhou

add tests and fix bugs

上级 afa6cdc3
......@@ -1877,7 +1877,7 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo, SSqlCmd* pCmd) {
// add the timestamp column into the output columns
SColumnIndex index = {0}; // primary timestamp column info
int32_t numOfCols = (int32_t)tscNumOfExprs(pQueryInfo);
int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo);
tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols);
......@@ -3060,14 +3060,15 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
SColumnList ids = createColumnList(1, index.tableIndex, index.columnIndex);
if (finalResult) {
insertResultField(pQueryInfo, colIndex, &ids, resultSize, (int8_t)resultType, pExpr->base.aliasName, pExpr);
int32_t numOfOutput = tscNumOfFields(pQueryInfo);
insertResultField(pQueryInfo, numOfOutput, &ids, pExpr->base.resBytes, (int32_t)pExpr->base.resType,
pExpr->base.aliasName, pExpr);
} else {
assert(ids.num == 1);
tscColumnListInsert(pQueryInfo->colList, ids.ids[0].columnIndex, pExpr->base.uid, pSchema);
}
tscInsertPrimaryTsSourceColumn(pQueryInfo, pExpr->base.uid);
return TSDB_CODE_SUCCESS;
}
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 500
sql connect
$dbPrefix = m_di_db
$tbPrefix = m_di_tb
$mtPrefix = m_di_mt
$tbNum = 2
$rowNum = 50
print =============== step1 create stable/table
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int)
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 0
$y = 0.25
while $x < $rowNum
$cc = $x * 60000
$ms = 1601481600000 + $cc
sql insert into $tb values ($ms , $x , $y , $x , $x , $x , $y , $x , $x , $x )
$x = $x + 1
$y = $y + 1
endw
$i = $i + 1
endw
print ================= step2
$i = 1
$tb = $tbPrefix . $i
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
if $data00 != 0 then
return -1
endi
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
print ===> $data90 , $data91 , $data92 , $data93 , $data94 , $data95
if $data94 != 813.169925001 then
return -1
endi
if $data95 != 19764.000000000 then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb where ts == 1601481600000
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
if $data00 != 0 then
return -1
endi
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
$stb = $mtPrefix . 0
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where ts == 1601481600000
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
if $data00 != 0 then
return -1
endi
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where c1 == 0
print ===> $data01 , $data02 , $data03 , $data04 , $data05
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb where c1 == 0
print ===> $data01 , $data02 , $data03 , $data04 , $data05
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $stb order by ts desc
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
if $data00 != 49 then
return -1
endi
if $data01 != 5.614709844 then
return -1
endi
if $data02 != 2401.000000000 then
return -1
endi
if $data03 != 2401.000000000 then
return -1
endi
if $data04 != 117649.000000000 then
return -1
endi
if $data05 != 5.614709844 then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from $tb order by ts limit 2;
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15
if $data00 != 0 then
return -1
endi
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data11 != 0.000000000 then
return -1
endi
if $data12 != 1.000000000 then
return -1
endi
if $data13 != 3.000000000 then
return -1
endi
if $data14 != 2.000000000 then
return -1
endi
if $data15 != 2.000000000 then
return -1
endi
print ===============> step 3 sql_error stable, group by, window
sql_error select log(c2,2) from $stb group by tbname;
sql_error select log(c2,2) from $stb group by tgcol;
sql_error select log(c2,2) from $stb group by c3;
sql_error select log(c2,2) from $stb interval(1m);
sql_error select log(c2,2) from $stb state_window(c7);
sql_error select log(c2,2) from $tb state_window(c7);
sql_error select log(c2,2) from $stb session(ts, 30s);
sql_error select log(c2,2) from $tb session(ts, 30s);
sql_error select log(c2,2) from $stb slimit 2;
sql_error select pow(c2,2) from $stb group by tbname;
sql_error select pow(c2,2) from $stb group by tgcol;
sql_error select pow(c2,2) from $stb group by c3;
sql_error select pow(c2,2) from $stb interval(1m);
sql_error select pow(c2,2) from $stb state_window(c7);
sql_error select pow(c2,2) from $tb state_window(c7);
sql_error select pow(c2,2) from $stb session(ts, 30s);
sql_error select pow(c2,2) from $tb session(ts, 30s);
sql_error select pow(c2,2) from $stb slimit 2;
sql_error select pow(c2,2) from $stb interval(1m) slimit 2;
print ===============> step 4 nested query
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $stb order by ts desc)
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
if $data00 != 49 then
return -1
endi
if $data01 != 5.614709844 then
return -1
endi
if $data02 != 2401.000000000 then
return -1
endi
if $data03 != 2403.000000000 then
return -1
endi
if $data04 != 117649.000000000 then
return -1
endi
if $data05 != 5.614709844 then
return -1
endi
sql select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from $tb order by ts limit 2);
print ===> $data00 , $data01 , $data02 , $data03 , $data04 , $data05
print ===> $data10 , $data11 , $data12 , $data13 , $data14 , $data15
if $data00 != 0 then
return -1
endi
if $data01 != -2.000000000 then
return -1
endi
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 2.062500000 then
return -1
endi
if $data04 != -inf then
return -1
endi
if $data05 != 0.000000000 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data11 != 0.000000000 then
return -1
endi
if $data12 != 1.000000000 then
return -1
endi
if $data13 != 3.000000000 then
return -1
endi
if $data14 != 2.000000000 then
return -1
endi
if $data15 != 2.000000000 then
return -1
endi
#print =============== clear
#sql drop database $db
#sql show databases
#if $rows != 0 then
# return -1
#endi
#
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
#
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册