From a7920d00ac3173b469363c05c8369d808ea303fd Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 10 Mar 2022 11:06:42 +0800 Subject: [PATCH] add test case & fix error --- src/client/src/tscSQLParser.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c84849abba..398f118466 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -8425,7 +8425,6 @@ static int32_t doTagFunctionCheck(SQueryInfo* pQueryInfo) { int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* msg) { const char* msg1 = "functions/columns not allowed in group by query"; - //const char* msg2 = "projection query on columns not allowed"; const char* msg3 = "group by/session/state_window not allowed on projection query"; const char* msg4 = "retrieve tags not compatible with group by or interval query"; const char* msg5 = "functions can not be mixed up"; @@ -8481,7 +8480,11 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION)) { for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) { SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j); - if (pColIndex->colIndex != TSDB_TBNAME_COLUMN_INDEX) { + if (j == 0) { + if (pColIndex->colIndex != TSDB_TBNAME_COLUMN_INDEX) { + return invalidOperationMsg(msg, msg6); + } + } else if (!TSDB_COL_IS_TAG(pColIndex->flag)) { return invalidOperationMsg(msg, msg6); } } @@ -8490,6 +8493,13 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* if (pQueryInfo->stateWindow && (f == TSDB_FUNC_UNIQUE || f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION)){ return invalidOperationMsg(msg, msg7); } + + if (IS_MULTIOUTPUT(aAggs[f].status) && f != TSDB_FUNC_TOP && f != TSDB_FUNC_BOTTOM && f != TSDB_FUNC_DIFF && + f != TSDB_FUNC_MAVG && f != TSDB_FUNC_CSUM && f != TSDB_FUNC_SAMPLE && + f != TSDB_FUNC_DERIVATIVE && f != TSDB_FUNC_TAGPRJ && f != TSDB_FUNC_PRJ && + f != TSDB_FUNC_UNIQUE && f != TSDB_FUNC_TAIL) { + return invalidOperationMsg(msg, msg1); + } } if (checkUpdateTagPrjFunctions(pQueryInfo, msg) != TSDB_CODE_SUCCESS) { -- GitLab