diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c73cce2d1b8c75771a89c99618c7f7965e18e665..86bf053c8fa59d550a21916310abd0d6a802d028 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -10117,12 +10117,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf if (f == TSDB_FUNC_STDDEV || f == TSDB_FUNC_PERCT) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } - - if ((timeWindowQuery || pQueryInfo->stateWindow) && f == TSDB_FUNC_LAST) { - pExpr->base.numOfParams = 1; - pExpr->base.param[0].i64 = TSDB_ORDER_ASC; - pExpr->base.param[0].nType = TSDB_DATA_TYPE_INT; - } } STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index a63c9ec2c231ae263cb61f15947256b7279646ed..84ae4bdb6b455718530bd3e74c4929c629cca81f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5120,8 +5120,6 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt } } - pQueryAttr->uniqueQuery = isFunctionQuery(numOfOutput, pQueryAttr->pExpr1, TSDB_FUNC_UNIQUE); - pQueryAttr->tableCols = calloc(numOfCols, sizeof(SColumnInfo)); for(int32_t i = 0; i < numOfCols; ++i) { SColumn* pCol = taosArrayGetP(pQueryInfo->colList, i); diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index b20d9e8de02ffa16592b5a1cc75a7ace23f56d67..a8b781718cafa7fdb381205609e97ea6f96fd409 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -223,7 +223,6 @@ typedef struct SQueryAttr { bool stableQuery; // super table query or not bool topBotQuery; // TODO used bitwise flag - bool uniqueQuery; bool groupbyColumn; // denote if this is a groupby normal column query bool hasTagResults; // if there are tag values in final result or not bool timeWindowInterpo;// if the time window start/end required interpolation @@ -734,5 +733,4 @@ void addTableReadRows(SQueryRuntimeEnv* pEnv, int32_t tid, int32_t rows); // tsdb scan table callback table or query is over. param is SQueryRuntimeEnv* bool qReadOverCB(void* param, int8_t type, int32_t tid); -bool isFunctionQuery(int32_t numOfOutput, SExprInfo* pExprs, int16_t functionId); #endif // TDENGINE_QEXECUTOR_H diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index fff9420999675c66ba8e0e0d202ee0d4753ca7f9..6cc3db3f394f19fe4449c7b370b24e5aa67c8c7c 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -291,7 +291,7 @@ static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeE if (pRuntimeEnv->pQueryAttr->order.orderColId <= 0){ return; } - + SColIndex* pColIndex = taosArrayGet(pRuntimeEnv->pQueryAttr->pGroupbyExpr->columnInfo, 0); int16_t dataOffset = 0; @@ -3162,7 +3162,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa if ((*status) != BLK_DATA_ALL_NEEDED) { // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, // the filter result may be incorrect. So in case of interval query, we need to set the correct time output buffer - if (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && (!pQueryAttr->pointInterpQuery) && (!pQueryAttr->uniqueQuery)) { + if (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && (!pQueryAttr->pointInterpQuery)) { SResultRow* pResult = NULL; bool masterScan = IS_MASTER_SCAN(pRuntimeEnv); @@ -3174,7 +3174,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } - } else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery) && (!pQueryAttr->pointInterpQuery) && (!pQueryAttr->uniqueQuery)) { // stable aggregate, not interval aggregate or normal column aggregate + } else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery) && (!pQueryAttr->pointInterpQuery)) { // stable aggregate, not interval aggregate or normal column aggregate doSetTableGroupOutputBuf(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pTableScanInfo->pCtx, pTableScanInfo->rowCellInfoOffset, pTableScanInfo->numOfOutput, pRuntimeEnv->current->groupIndex); @@ -3922,15 +3922,6 @@ void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResult } } -bool isFunctionQuery(int32_t numOfOutput, SExprInfo* pExprs, int16_t functionId) { - for (int32_t i = 0; i < numOfOutput; ++i) { - if (pExprs[i].base.functionId == functionId) { - return true; - } - } - return false; -} - static bool hasMainOutput(SQueryAttr *pQueryAttr) { for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { int32_t functionId = pQueryAttr->pExpr1[i].base.functionId; @@ -5256,8 +5247,6 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { qDebug("QInfo:0x%"PRIx64" start to reverse scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64, GET_QID(pRuntimeEnv), cond.twindow.skey, cond.twindow.ekey); - pRuntimeEnv->scanFlag = REVERSE_SCAN; - pTableScanInfo->times = 1; pTableScanInfo->current = 0; pTableScanInfo->reverseTimes = 0; @@ -6852,7 +6841,6 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) { } SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - int32_t order = pQueryAttr->order.order; SOperatorInfo* upstream = pOperator->upstream[0]; @@ -6883,7 +6871,6 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) { } pOperator->status = OP_RES_TO_RETURN; - pQueryAttr->order.order = order; // TODO : restore the order doCloseAllTimeWindow(pRuntimeEnv); setQueryStatus(pRuntimeEnv, QUERY_COMPLETED); @@ -9568,7 +9555,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S pQueryAttr->vgId = vgId; pQueryAttr->pFilters = pFilters; pQueryAttr->range = pQueryMsg->range; - pQueryAttr->uniqueQuery = isFunctionQuery(numOfOutput, pExprs, TSDB_FUNC_UNIQUE); pQueryAttr->tableCols = calloc(numOfCols, sizeof(SSingleColumnFilterInfo)); if (pQueryAttr->tableCols == NULL) { diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index 6aebb32191813ee7bdc79628246e8c2dddba79ee..8e39af3e6bc542f958bffd04413e92b4b242a7a3 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -42,9 +42,10 @@ int32_t getRowNumForMultioutput(SQueryAttr* pQueryAttr, bool topBottomQuery, boo pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_TAIL) { return (int32_t)pQueryAttr->pExpr1[i].base.param[0].i64; } - } - if (pQueryAttr->uniqueQuery){ - return MAX_UNIQUE_RESULT_ROWS; + + if (pQueryAttr->pExpr1[i].base.functionId == TSDB_FUNC_UNIQUE){ + return MAX_UNIQUE_RESULT_ROWS; + } } }