Merge pull request #15181 from taosdata/fix/TD-17511
fix(query): twa function handling null constant or all null column
This commit is contained in:
commit
5a0668dadd
|
@ -165,6 +165,7 @@ typedef struct SElapsedInfo {
|
||||||
|
|
||||||
typedef struct STwaInfo {
|
typedef struct STwaInfo {
|
||||||
double dOutput;
|
double dOutput;
|
||||||
|
bool isNull;
|
||||||
SPoint1 p;
|
SPoint1 p;
|
||||||
STimeWindow win;
|
STimeWindow win;
|
||||||
} STwaInfo;
|
} STwaInfo;
|
||||||
|
@ -5181,8 +5182,9 @@ bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STwaInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
STwaInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
pInfo->p.key = INT64_MIN;
|
pInfo->isNull = false;
|
||||||
pInfo->win = TSWINDOW_INITIALIZER;
|
pInfo->p.key = INT64_MIN;
|
||||||
|
pInfo->win = TSWINDOW_INITIALIZER;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5208,27 +5210,47 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
SPoint1* last = &pInfo->p;
|
SPoint1* last = &pInfo->p;
|
||||||
int32_t numOfElems = 0;
|
int32_t numOfElems = 0;
|
||||||
|
|
||||||
|
if (IS_NULL_TYPE(pInputCol->info.type)) {
|
||||||
|
pInfo->isNull = true;
|
||||||
|
goto _twa_over;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t i = pInput->startRowIndex;
|
int32_t i = pInput->startRowIndex;
|
||||||
if (pCtx->start.key != INT64_MIN) {
|
if (pCtx->start.key != INT64_MIN) {
|
||||||
ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
|
ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
|
||||||
(pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
|
(pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
|
||||||
|
|
||||||
ASSERT(last->key == INT64_MIN);
|
ASSERT(last->key == INT64_MIN);
|
||||||
last->key = tsList[i];
|
for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
last->key = tsList[i];
|
||||||
|
|
||||||
pInfo->dOutput += twa_get_area(pCtx->start, *last);
|
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||||
pInfo->win.skey = pCtx->start.key;
|
|
||||||
numOfElems++;
|
pInfo->dOutput += twa_get_area(pCtx->start, *last);
|
||||||
i += 1;
|
pInfo->win.skey = pCtx->start.key;
|
||||||
|
numOfElems++;
|
||||||
|
i += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (pInfo->p.key == INT64_MIN) {
|
} else if (pInfo->p.key == INT64_MIN) {
|
||||||
last->key = tsList[i];
|
for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||||
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->win.skey = last->key;
|
last->key = tsList[i];
|
||||||
numOfElems++;
|
|
||||||
i += 1;
|
GET_TYPED_DATA(last->val, double, pInputCol->info.type, colDataGetData(pInputCol, i));
|
||||||
|
|
||||||
|
pInfo->win.skey = last->key;
|
||||||
|
numOfElems++;
|
||||||
|
i += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPoint1 st = {0};
|
SPoint1 st = {0};
|
||||||
|
@ -5241,6 +5263,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5255,6 +5278,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5268,6 +5292,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5281,6 +5306,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5294,6 +5320,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5307,6 +5334,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5320,6 +5348,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5333,6 +5362,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5346,6 +5376,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5359,6 +5390,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
numOfElems++;
|
||||||
|
|
||||||
INIT_INTP_POINT(st, tsList[i], val[i]);
|
INIT_INTP_POINT(st, tsList[i], val[i]);
|
||||||
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
pInfo->dOutput += twa_get_area(pInfo->p, st);
|
||||||
|
@ -5379,7 +5411,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
pInfo->win.ekey = pInfo->p.key;
|
pInfo->win.ekey = pInfo->p.key;
|
||||||
|
|
||||||
SET_VAL(pResInfo, numOfElems, 1);
|
_twa_over:
|
||||||
|
if (numOfElems == 0) {
|
||||||
|
pInfo->isNull = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_VAL(pResInfo, 1, 1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5400,8 +5437,8 @@ int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
STwaInfo* pInfo = (STwaInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
STwaInfo* pInfo = (STwaInfo*)GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
if (pResInfo->numOfRes == 0) {
|
if (pInfo->isNull == true) {
|
||||||
pResInfo->isNullRes = 1;
|
pResInfo->numOfRes = 0;
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->win.ekey == pInfo->win.skey) {
|
if (pInfo->win.ekey == pInfo->win.skey) {
|
||||||
pInfo->dOutput = pInfo->p.val;
|
pInfo->dOutput = pInfo->p.val;
|
||||||
|
|
|
@ -11,13 +11,13 @@ class TDTestCase:
|
||||||
self.row_nums = 10
|
self.row_nums = 10
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
|
||||||
def prepare_datas(self, stb_name , tb_nums , row_nums ):
|
def prepare_datas(self, stb_name , tb_nums , row_nums ):
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
|
tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
|
||||||
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
|
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
|
||||||
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
|
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
|
||||||
|
|
||||||
for i in range(tb_nums):
|
for i in range(tb_nums):
|
||||||
tbname = f"sub_{stb_name}_{i}"
|
tbname = f"sub_{stb_name}_{i}"
|
||||||
ts = self.ts + i*10000
|
ts = self.ts + i*10000
|
||||||
|
@ -30,7 +30,7 @@ class TDTestCase:
|
||||||
for null in range(5):
|
for null in range(5):
|
||||||
ts = self.ts + row_nums*1000 + null*1000
|
ts = self.ts + row_nums*1000 + null*1000
|
||||||
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
|
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
|
||||||
|
|
||||||
def basic_query(self):
|
def basic_query(self):
|
||||||
tdSql.query("select count(*) from stb")
|
tdSql.query("select count(*) from stb")
|
||||||
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
|
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
|
||||||
|
@ -44,7 +44,7 @@ class TDTestCase:
|
||||||
tdSql.query(" select max(t2) from stb group by c1 order by t1 ")
|
tdSql.query(" select max(t2) from stb group by c1 order by t1 ")
|
||||||
tdSql.query(" select max(c1) from stb group by tbname order by tbname ")
|
tdSql.query(" select max(c1) from stb group by tbname order by tbname ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
# bug need fix
|
# bug need fix
|
||||||
tdSql.query(" select max(t2) from stb group by t2 order by t2 ")
|
tdSql.query(" select max(t2) from stb group by t2 order by t2 ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.query(" select max(c1) from stb group by c1 order by c1 ")
|
tdSql.query(" select max(c1) from stb group by c1 order by c1 ")
|
||||||
|
@ -62,8 +62,8 @@ class TDTestCase:
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ")
|
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
# tdSql.checkData(0,0,"sub_stb_1")
|
# tdSql.checkData(0,0,"sub_stb_1")
|
||||||
|
|
||||||
tdSql.query("select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)")
|
tdSql.query("select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
@ -80,7 +80,7 @@ class TDTestCase:
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.query(" select max(c1) from stb where abs(c1+t2)=1 partition by tbname ")
|
tdSql.query(" select max(c1) from stb where abs(c1+t2)=1 partition by tbname ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname ")
|
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,1,self.row_nums-1)
|
tdSql.checkData(0,1,self.row_nums-1)
|
||||||
|
@ -89,7 +89,7 @@ class TDTestCase:
|
||||||
tdSql.query("select tbname , max(t2) from stb partition by t1 order by t1")
|
tdSql.query("select tbname , max(t2) from stb partition by t1 order by t1")
|
||||||
tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2")
|
tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2")
|
||||||
|
|
||||||
# # bug need fix
|
# # bug need fix
|
||||||
tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2")
|
tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class TDTestCase:
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,1,self.row_nums-1)
|
tdSql.checkData(0,1,self.row_nums-1)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select tbname , max(c1) from stb partition by t2 order by t2")
|
tdSql.query("select tbname , max(c1) from stb partition by t2 order by t2")
|
||||||
|
|
||||||
tdSql.query("select c2, max(c1) from stb partition by c2 order by c2 desc")
|
tdSql.query("select c2, max(c1) from stb partition by c2 order by c2 desc")
|
||||||
|
@ -125,10 +125,10 @@ class TDTestCase:
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,0,self.row_nums)
|
tdSql.checkData(0,0,self.row_nums)
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
|
tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
|
tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
@ -148,15 +148,15 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ")
|
tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ")
|
||||||
tdSql.checkRows(self.tb_nums*2)
|
tdSql.checkRows(self.tb_nums*2)
|
||||||
|
|
||||||
|
|
||||||
# interval
|
|
||||||
|
# interval
|
||||||
tdSql.query("select max(c1) from stb interval(2s) sliding(1s)")
|
tdSql.query("select max(c1) from stb interval(2s) sliding(1s)")
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
|
|
||||||
tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
|
tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
|
||||||
|
|
||||||
tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ")
|
tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ")
|
||||||
|
|
||||||
tdSql.query("select tbname , max(c1) from stb partition by tbname interval(10s)")
|
tdSql.query("select tbname , max(c1) from stb partition by tbname interval(10s)")
|
||||||
|
@ -179,12 +179,12 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query("select c1 , sample(c1,2) from stb partition by c1 order by c1")
|
tdSql.query("select c1 , sample(c1,2) from stb partition by c1 order by c1")
|
||||||
tdSql.checkRows(21)
|
tdSql.checkRows(21)
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.checkData(0,1,None)
|
# tdSql.checkData(0,1,None)
|
||||||
|
|
||||||
tdSql.query("select c1 , twa(c1) from stb partition by c1 order by c1")
|
tdSql.query("select c1 , twa(c1) from stb partition by c1 order by c1")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(11)
|
||||||
tdSql.checkData(0,1,0.000000000)
|
tdSql.checkData(0,1,None)
|
||||||
|
|
||||||
tdSql.query("select c1 , irate(c1) from stb partition by c1 order by c1")
|
tdSql.query("select c1 , irate(c1) from stb partition by c1 order by c1")
|
||||||
tdSql.checkRows(11)
|
tdSql.checkRows(11)
|
||||||
|
@ -192,7 +192,7 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1")
|
tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1")
|
||||||
tdSql.checkRows(72)
|
tdSql.checkRows(72)
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.checkData(0,1,None)
|
# tdSql.checkData(0,1,None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,15 +201,15 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
||||||
# tdSql.checkRows(5)
|
# tdSql.checkRows(5)
|
||||||
|
|
||||||
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ")
|
# tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ")
|
||||||
# tdSql.checkRows(5)
|
# tdSql.checkRows(5)
|
||||||
|
|
||||||
tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
|
tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
|
||||||
|
|
||||||
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
||||||
tdSql.query(f'select tbname , max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
tdSql.query(f'select tbname , max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
||||||
|
|
||||||
|
@ -219,18 +219,18 @@ class TDTestCase:
|
||||||
self.prepare_datas("stb",self.tb_nums,self.row_nums)
|
self.prepare_datas("stb",self.tb_nums,self.row_nums)
|
||||||
self.basic_query()
|
self.basic_query()
|
||||||
|
|
||||||
# # coverage case for taosd crash about bug fix
|
# # coverage case for taosd crash about bug fix
|
||||||
tdSql.query(" select sum(c1) from stb where t2+10 >1 ")
|
tdSql.query(" select sum(c1) from stb where t2+10 >1 ")
|
||||||
tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ")
|
tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ")
|
||||||
tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ")
|
tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ")
|
||||||
tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ")
|
tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ")
|
||||||
tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ")
|
tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ")
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success("%s successfully executed" % __file__)
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
|
|
@ -7,7 +7,7 @@ import platform
|
||||||
import math
|
import math
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
|
@ -22,7 +22,7 @@ class TDTestCase:
|
||||||
self.time_step = 1000
|
self.time_step = 1000
|
||||||
|
|
||||||
def prepare_datas_of_distribute(self):
|
def prepare_datas_of_distribute(self):
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(" use testdb ")
|
||||||
|
@ -32,16 +32,16 @@ class TDTestCase:
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(self.tb_nums):
|
for i in range(self.tb_nums):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
ts = self.ts
|
ts = self.ts
|
||||||
for j in range(self.row_nums):
|
for j in range(self.row_nums):
|
||||||
ts+=j*self.time_step
|
ts+=j*self.time_step
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct{i+1} values({ts}, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into ct{i+1} values({ts}, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute("insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute("insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute("insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute("insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
@ -64,7 +64,7 @@ class TDTestCase:
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
|
||||||
for vgroup_id in vgroups:
|
for vgroup_id in vgroups:
|
||||||
vnode_tables[vgroup_id[0]]=[]
|
vnode_tables[vgroup_id[0]]=[]
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class TDTestCase:
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
vnode_tables[table_name[6]].append(table_name[0])
|
vnode_tables[table_name[6]].append(table_name[0])
|
||||||
self.vnode_disbutes = vnode_tables
|
self.vnode_disbutes = vnode_tables
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -103,12 +103,12 @@ class TDTestCase:
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,0,1.000000000)
|
tdSql.checkData(0,0,1.000000000)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query(" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname ")
|
tdSql.query(" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname ")
|
||||||
tdSql.checkRows(40)
|
tdSql.checkRows(40)
|
||||||
tdSql.checkData(0,0,1.000000000)
|
tdSql.checkData(0,0,1.000000000)
|
||||||
|
|
||||||
# join
|
# join
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
|
@ -116,7 +116,7 @@ class TDTestCase:
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table tb1 using st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table tb2 using st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
||||||
|
@ -127,7 +127,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,0,4.500000000)
|
tdSql.checkData(0,0,4.500000000)
|
||||||
tdSql.checkData(0,1,4.500000000)
|
tdSql.checkData(0,1,4.500000000)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(" use testdb ")
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
|
@ -141,7 +141,7 @@ class TDTestCase:
|
||||||
self.check_distribute_datas()
|
self.check_distribute_datas()
|
||||||
self.twa_support_types()
|
self.twa_support_types()
|
||||||
self.distribute_twa_query()
|
self.distribute_twa_query()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success("%s successfully executed" % __file__)
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
Loading…
Reference in New Issue