feat(query): add mavg function
This commit is contained in:
parent
8d21c662aa
commit
1e503061ed
|
@ -3013,18 +3013,22 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) {
|
||||||
} else {
|
} else {
|
||||||
pInfo->sum = pInfo->sum + v - pInfo->points[pInfo->pos];
|
pInfo->sum = pInfo->sum + v - pInfo->points[pInfo->pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->points[pInfo->pos] = v;
|
||||||
|
double result = pInfo->sum / pInfo->numOfPoints;
|
||||||
|
colDataAppend(pOutput, pos, (char *)&result, false);
|
||||||
|
|
||||||
|
//TODO: remove this after pTsOutput is handled
|
||||||
|
if (pTsOutput != NULL) {
|
||||||
|
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
||||||
|
}
|
||||||
|
numOfElems++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->points[pInfo->pos] = v;
|
pInfo->pos++;
|
||||||
double result = pInfo->sum / pInfo->numOfPoints;
|
if (pInfo->pos == pInfo->numOfPoints) {
|
||||||
colDataAppend(pOutput, pos, (char *)&result, false);
|
pInfo->pos = 0;
|
||||||
|
|
||||||
//TODO: remove this after pTsOutput is handled
|
|
||||||
if (pTsOutput != NULL) {
|
|
||||||
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfElems++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
|
|
Loading…
Reference in New Issue