diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 9011bae47ba78945e4f87dabb91cbb1d5d900d9e..89f2563e148bdc94e53b6cf004b356d232a06364 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -3477,6 +3477,7 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) { if (pSql->res.code == TSDB_CODE_SUCCESS) { (*pSql->fp)(pParentSql->param, pParentSql, pParentSql->res.numOfRows); } else { + pParentSql->res.code = pSql->res.code; tscAsyncResultOnError(pParentSql); } } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 68de90255643ee6ceae6b560cd53226827c29017..bc14c75af561706a214fb950d2ae8567ef2c442c 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -3613,16 +3613,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) { qError("error input type"); } - // initial value is not set yet, all data block are null - if (!pDerivInfo->valueSet || notNullElems <= 0) { - /* - * 1. current block and blocks before are full of null - * 2. current block may be null value - */ - assert(pCtx->hasNull); - } else { - GET_RES_INFO(pCtx)->numOfRes += notNullElems; - } + GET_RES_INFO(pCtx)->numOfRes += notNullElems; } #define DIFF_IMPL(ctx, d, type) \ diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index ad900b92e01ca46b7f4fb8afbd30a5a408bfb7ac..827f21f0bf40b0f72facafff7a3d4f14904f0a2e 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -1073,6 +1073,12 @@ sql insert into t0 values('2020-1-1 1:3:9', 9); sql insert into t0 values('2020-1-1 1:4:10', 10); sql insert into t1 values('2020-1-1 1:1:2', 2); +print ===========================>td-4739 +sql select diff(val) from (select derivative(k, 1s, 0) from t1); +if $rows != 0 then + return -1 +endi + sql insert into t1 values('2020-1-1 1:1:4', 20); sql insert into t1 values('2020-1-1 1:1:6', 200); sql insert into t1 values('2020-1-1 1:1:8', 2000);