Merge pull request #6744 from taosdata/hotfix/TD-5042
[TD-5042]fix diff group by crash issue
This commit is contained in:
commit
2bf253d336
|
@ -6538,6 +6538,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char*
|
|||
const char* msg3 = "group by/session/state_window not allowed on projection query";
|
||||
const char* msg4 = "retrieve tags not compatible with group by or interval query";
|
||||
const char* msg5 = "functions can not be mixed up";
|
||||
const char* msg6 = "TWA/Diff/Derivative/Irate only support group by tbname";
|
||||
|
||||
// only retrieve tags, group by is not supportted
|
||||
if (tscQueryTags(pQueryInfo)) {
|
||||
|
@ -6589,6 +6590,19 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char*
|
|||
}
|
||||
}
|
||||
|
||||
if ((!pQueryInfo->stateWindow) && (f == TSDB_FUNC_DIFF || f == TSDB_FUNC_DERIVATIVE || f == TSDB_FUNC_TWA || f == TSDB_FUNC_IRATE)) {
|
||||
for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) {
|
||||
SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j);
|
||||
if (j == 0) {
|
||||
if (pColIndex->colIndex != TSDB_TBNAME_COLUMN_INDEX) {
|
||||
return invalidOperationMsg(msg, msg6);
|
||||
}
|
||||
} else if (!TSDB_COL_IS_TAG(pColIndex->flag)) {
|
||||
return invalidOperationMsg(msg, msg6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_MULTIOUTPUT(aAggs[f].status) && f != TSDB_FUNC_TOP && f != TSDB_FUNC_BOTTOM &&
|
||||
f != TSDB_FUNC_DIFF && f != TSDB_FUNC_DERIVATIVE && f != TSDB_FUNC_TAGPRJ && f != TSDB_FUNC_PRJ) {
|
||||
return invalidOperationMsg(msg, msg1);
|
||||
|
|
|
@ -1407,8 +1407,9 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
|
|||
}
|
||||
|
||||
doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, pSDataBlock->info.rows - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput);
|
||||
tfree(pInfo->prevData);
|
||||
}
|
||||
|
||||
tfree(pInfo->prevData);
|
||||
}
|
||||
|
||||
static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInfo *pInfo, SSDataBlock *pSDataBlock) {
|
||||
|
|
|
@ -114,8 +114,7 @@ class TDTestCase:
|
|||
tdSql.query("select first(ts),twa(c) from tb interval(14a)")
|
||||
tdSql.checkRows(6)
|
||||
|
||||
tdSql.query("select twa(c) from tb group by c")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.error("select twa(c) from tb group by c")
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -692,6 +692,7 @@ if $data31 != 4 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql_error select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,c;
|
||||
sql select irate(c) from st where t1="1" and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' interval(1m) sliding(15s) group by tbname,t1,t2;
|
||||
if $rows != 40 then
|
||||
return -1
|
||||
|
|
|
@ -306,41 +306,11 @@ endi
|
|||
|
||||
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having twa(f1) > 0;
|
||||
|
||||
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having twa(f1) > 3;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 4.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 4.000000000 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having twa(f1) > 3;
|
||||
|
||||
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having sum(f1) > 0;
|
||||
|
||||
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having sum(f1) = 4;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 2.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 2.000000000 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having sum(f1) = 4;
|
||||
|
||||
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 0;
|
||||
if $rows != 4 then
|
||||
|
|
Loading…
Reference in New Issue