Merge pull request #17840 from taosdata/feature/TD-19844
fix(function):if data is null, apercentile function should return null
This commit is contained in:
commit
079704599c
|
@ -1913,6 +1913,22 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
|
|
|
@ -2713,7 +2713,9 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
taosMemoryFree(res);
|
||||
} else { // no need to free
|
||||
// setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
qDebug("%s get the final res, elements:%" PRId64 ", numOfEntry:%d. result is null", __FUNCTION__,
|
||||
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1013,4 +1013,68 @@ sql_error select sum(cast(_wend as bigint)), a from ft1 state_window(a);
|
|||
|
||||
sql_error create stream streams1 trigger at_once into streamt as select _wstart, sum(_wduration) from ft1 interval(10s);
|
||||
|
||||
sql_error create stream streams1 trigger at_once into streamt as select _wstart, sum(cast(_wend as bigint)) from ft1 interval(10s);
|
||||
sql_error create stream streams1 trigger at_once into streamt as select _wstart, sum(cast(_wend as bigint)) from ft1 interval(10s);
|
||||
|
||||
sql create database test vgroups 1;
|
||||
sql use test;
|
||||
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||
sql insert into t1 values(1648791213000,1,1,3,1.0);
|
||||
sql insert into t1 values(1648791223000,1,2,NULL,NULL);
|
||||
|
||||
sleep 200
|
||||
|
||||
sql select apercentile(c, 50), apercentile(d, 50, "t-digest") from t1;
|
||||
|
||||
if $data00 != 3.000000000 then
|
||||
print ======data00=$data00
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1.000000000 then
|
||||
print ======data01=$data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select apercentile(c, 50) a, apercentile(d, 50, "t-digest") from t1 partition by b session(ts, 5s) order by a desc;
|
||||
|
||||
if $data00 != 3.000000000 then
|
||||
print ======data00=$data00
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1.000000000 then
|
||||
print ======data01=$data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != NULL then
|
||||
print ======data10=$data10
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != NULL then
|
||||
print ======data11=$data11
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select apercentile(c, 50) a, apercentile(d, 50, "t-digest") from t1 state_window(b) order by a desc;
|
||||
|
||||
if $data00 != 3.000000000 then
|
||||
print ======data00=$data00
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1.000000000 then
|
||||
print ======data01=$data01
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != NULL then
|
||||
print ======data10=$data10
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != NULL then
|
||||
print ======data11=$data11
|
||||
return -1
|
||||
endi
|
Loading…
Reference in New Issue