提交 9ef2d736 编写于 作者: G Ganlin Zhao

fix(query): fix elapsed order by ts desc result inconsist after flush

to disk

TD-18453
上级 6de1ce0f
...@@ -3970,16 +3970,16 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) { ...@@ -3970,16 +3970,16 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
TSKEY* ptsList = (int64_t*)colDataGetData(pCol, 0); TSKEY* ptsList = (int64_t*)colDataGetData(pCol, 0);
if (pCtx->order == TSDB_ORDER_DESC) { if (pCtx->order == TSDB_ORDER_DESC) {
if (pCtx->start.key == INT64_MIN) { if (pCtx->start.key == INT64_MIN) {
pInfo->max = pInfo->max = (pInfo->max < ptsList[start]) ? ptsList[start] : pInfo->max;
(pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->max;
} else { } else {
pInfo->max = pCtx->start.key + 1; pInfo->max = pCtx->start.key + 1;
} }
if (pCtx->end.key != INT64_MIN) { if (pCtx->end.key == INT64_MIN) {
pInfo->min = pCtx->end.key; pInfo->min = (pInfo->min > ptsList[start + pInput->numOfRows - 1]) ?
ptsList[start + pInput->numOfRows - 1] : pInfo->min;
} else { } else {
pInfo->min = ptsList[start]; pInfo->min = pCtx->end.key;
} }
} else { } else {
if (pCtx->start.key == INT64_MIN) { if (pCtx->start.key == INT64_MIN) {
...@@ -3988,10 +3988,11 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) { ...@@ -3988,10 +3988,11 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
pInfo->min = pCtx->start.key; pInfo->min = pCtx->start.key;
} }
if (pCtx->end.key != INT64_MIN) { if (pCtx->end.key == INT64_MIN) {
pInfo->max = pCtx->end.key + 1; pInfo->max = (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ?
ptsList[start + pInput->numOfRows - 1] : pInfo->max;
} else { } else {
pInfo->max = ptsList[start + pInput->numOfRows - 1]; pInfo->max = pCtx->end.key + 1;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册