Merge pull request #12717 from taosdata/feature/udf
fix: udf2 reuse old state when new input is all null
This commit is contained in:
commit
5049ea17e6
|
@ -26,7 +26,7 @@ int32_t udf2_start(SUdfInterBuf *buf) {
|
||||||
|
|
||||||
int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
||||||
double sumSquares = *(double*)interBuf->buf;
|
double sumSquares = *(double*)interBuf->buf;
|
||||||
int8_t numOutput = 0;
|
int8_t numNotNull = 0;
|
||||||
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
||||||
SUdfColumn* col = block->udfCols[i];
|
SUdfColumn* col = block->udfCols[i];
|
||||||
if (!(col->colMeta.type == TSDB_DATA_TYPE_INT ||
|
if (!(col->colMeta.type == TSDB_DATA_TYPE_INT ||
|
||||||
|
@ -56,15 +56,14 @@ int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInte
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
numOutput = 1;
|
++numNotNull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOutput == 1) {
|
*(double*)(newInterBuf->buf) = sumSquares;
|
||||||
*(double*)(newInterBuf->buf) = sumSquares;
|
newInterBuf->bufLen = sizeof(double);
|
||||||
newInterBuf->bufLen = sizeof(double);
|
|
||||||
}
|
if (interBuf->numOfResult == 0 && numNotNull == 0) {
|
||||||
if (interBuf->numOfResult == 0 && numOutput == 0) {
|
|
||||||
newInterBuf->numOfResult = 0;
|
newInterBuf->numOfResult = 0;
|
||||||
} else {
|
} else {
|
||||||
newInterBuf->numOfResult = 1;
|
newInterBuf->numOfResult = 1;
|
||||||
|
|
Loading…
Reference in New Issue