fix(query): twa function output NULL if input has overlap timestamps

TD-18224
This commit is contained in:
Ganlin Zhao 2022-09-13 16:45:40 +08:00
parent 566af3ea92
commit 0d7e1eb4e0
1 changed files with 52 additions and 2 deletions

View File

@ -5398,8 +5398,8 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
int32_t i = pInput->startRowIndex;
if (pCtx->start.key != INT64_MIN) {
ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
(pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
//ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
// (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
ASSERT(last->key == INT64_MIN);
for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
@ -5446,6 +5446,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5461,6 +5466,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5475,6 +5485,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5489,6 +5504,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5503,6 +5523,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5517,6 +5542,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5531,6 +5561,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5545,6 +5580,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5559,6 +5599,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;
@ -5573,6 +5618,11 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
numOfElems++;
if (pInfo->p.key == st.key) {
numOfElems = 0;
goto _twa_over;
}
INIT_INTP_POINT(st, tsList[i], val[i]);
pInfo->dOutput += twa_get_area(pInfo->p, st);
pInfo->p = st;