提交 b64c30cf 编写于 作者: H Haojun Liao

[TD-2610]<fix>: fix twa bug in case of all data is NULL.

上级 fe15fc8a
......@@ -3810,11 +3810,15 @@ static void twa_function(SQLFunctionCtx *pCtx) {
// skip null value
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
int32_t i = (pCtx->order == TSDB_ORDER_ASC)? 0:(pCtx->size - 1);
while (pCtx->hasNull && i < pCtx->size && isNull((char *)data + pCtx->inputBytes * i, pCtx->inputType)) {
while (pCtx->hasNull && i < pCtx->size && i >= 0 && isNull((char *)data + pCtx->inputBytes * i, pCtx->inputType)) {
i += step;
}
int32_t notNullElems = twa_function_impl(pCtx, pCtx->startOffset, i, pCtx->size);
int32_t notNullElems = 0;
if (i >= 0 && i < pCtx->size) {
notNullElems = twa_function_impl(pCtx, pCtx->startOffset, i, pCtx->size);
}
SET_VAL(pCtx, notNullElems, 1);
if (notNullElems > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册