diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e8c3991aac4241154f3223dfb349a3f8dbec57b7..c901270de11a809b7455301a149647470117290a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3359,11 +3359,6 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col } else { tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT, true); - int64_t numRowsSelected = GET_INT64_VAL(val); - if (functionId != TSDB_FUNC_UNIQUE && (numRowsSelected <= 0 || numRowsSelected > 100)) { // todo use macro - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg12); - } - if(functionId == TSDB_FUNC_UNIQUE){ // consider of memory size if(pSchema->bytes < 10){ GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 100; @@ -3373,6 +3368,11 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS; } } + + int64_t numRowsSelected = GET_INT64_VAL(val); + if (functionId != TSDB_FUNC_UNIQUE && (numRowsSelected <= 0 || numRowsSelected > 100)) { // todo use macro + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg12); + } // todo REFACTOR // set the first column ts for top/bottom query SColumnIndex index1 = {index.tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX}; @@ -3385,9 +3385,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col aAggs[TSDB_FUNC_TS].name, pExpr); colIndex += 1; // the first column is ts - + getResultDataInfo(pSchema->type, pSchema->bytes, functionId, (int32_t)numRowsSelected, &resultType, + &resultSize, &interResult, 0, false, pUdfInfo); pExpr = tscExprAppend(pQueryInfo, functionId, &index, resultType, resultSize, getNewResColId(pCmd), - resultSize, false); + interResult, false); if (functionId == TSDB_FUNC_TAIL){ int64_t offset = 0; if (taosArrayGetSize(pItem->pNode->Expr.paramList) == 3){ diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 653df4baa1db9e2d13ebbcae5b11b9af93a2d1c5..04124b108de476d4556930b591fc54568d111001 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1491,7 +1491,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue pex->base.param[2].nType = TSDB_DATA_TYPE_INT; pex->base.param[2].i64 = pInputQI->order.order; } - } + } } tscDebug("0x%"PRIx64" create QInfo 0x%"PRIx64" to execute the main query while all nest queries are ready", pSql->self, pSql->self);