diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 7651e175d335c38fd094b7227db88b70db77d246..324a9ba9e9d938b8675b64477549d87573e74549 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2759,7 +2759,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (pItem->pNode->Expr.paramList == NULL || (functionId != TSDB_FUNC_LEASTSQR && functionId != TSDB_FUNC_DERIVATIVE && functionId != TSDB_FUNC_ELAPSED && numOfParams != 1) || ((functionId == TSDB_FUNC_LEASTSQR || functionId == TSDB_FUNC_DERIVATIVE) && numOfParams != 3) || - (functionId == TSDB_FUNC_ELAPSED && numOfParams > 2)) { + (functionId == TSDB_FUNC_ELAPSED && numOfParams != 1 && numOfParams != 2)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } diff --git a/tests/pytest/functions/function_elapsed_case.py b/tests/pytest/functions/function_elapsed_case.py index 56610a9347c3ab90a9addc64dd62a6ed60758abf..6b279d7f63de0cdbd854457350b670520ea455ec 100644 --- a/tests/pytest/functions/function_elapsed_case.py +++ b/tests/pytest/functions/function_elapsed_case.py @@ -320,6 +320,8 @@ class ElapsedCase: def selectIllegalTest(self): tdSql.execute("use wxy_db") + tdSql.error("select elapsed() from t1") + tdSql.error("select elapsed(,) from t1") tdSql.error("select elapsed(1) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'") tdSql.error("select elapsed('2021-11-18 00:00:10') from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'") tdSql.error("select elapsed(now) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'")