提交 0d7e1eb4 编写于 作者: G Ganlin Zhao

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

TD-18224
上级 566af3ea
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册