From a83df555e1c27f56dc669a5b02019f696a8f1785 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 21 Dec 2021 13:17:10 +0800 Subject: [PATCH] [TD-12342] give error tips if group by ts order by tag --- src/client/src/tscSQLParser.c | 7 +++---- .../2-query/0-aggregate/TD-12340-12342.py | 13 ------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 955eaa32f0..01d29c3bad 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6288,7 +6288,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq const char* msg0 = "only one column allowed in orderby"; const char* msg1 = "invalid column name in orderby clause"; const char* msg2 = "too many order by columns"; - const char* msg3 = "only primary timestamp, first tag/tbname in groupby clause allowed as order column"; + const char* msg3 = "only primary timestamp, tag/tbname in groupby clause allowed as order column"; const char* msg4 = "only tag in groupby clause allowed in order clause"; const char* msg5 = "only primary timestamp/column in top/bottom function allowed as order column"; const char* msg6 = "only primary timestamp allowed as the second order column"; @@ -6310,8 +6310,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq SArray* pSortOrder = pSqlNode->pSortOrder; /* - * for table query, there is only one or none order option is allowed, which is the - * ts or values(top/bottom) order is supported. + * for table query, there is only one or none order option is allowed * * for super table query, the order option must be less than 3 and the second must be ts. * @@ -6386,7 +6385,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg4); } SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, 0); - if (relTagIndex == pColIndex->colIndex) { + if (relTagIndex == pColIndex->colIndex && pColIndex->flag == TSDB_COL_TAG) { if (tscGetColumnSchemaById(pTableMetaInfo->pTableMeta, pColIndex->colId)->type == TSDB_DATA_TYPE_JSON){ if(!pItem->isJsonExp){ return invalidOperationMsg(pMsgBuf, msg14); diff --git a/tests/system-test/2-query/0-aggregate/TD-12340-12342.py b/tests/system-test/2-query/0-aggregate/TD-12340-12342.py index 360734f597..b190e94a9e 100644 --- a/tests/system-test/2-query/0-aggregate/TD-12340-12342.py +++ b/tests/system-test/2-query/0-aggregate/TD-12340-12342.py @@ -47,18 +47,6 @@ class TDTestCase: pass - def check_td12340(self): - # this case expect return two column when using "group by ts" - tdSql.query("select count(*) from stb1 group by ts") - try: - tdSql.checkCols(2) - self.curret_case += 1 - tdLog.printNoPrefix("the case1: td-12340 run passed") - except: - self.err_case += 1 - tdLog.printNoPrefix("the case1: td-12340 run failed") - pass - def check_td12342(self): # this case expect return err when using "group by ts order by first-tag" try: @@ -73,7 +61,6 @@ class TDTestCase: def run(self): self.create_stb() - self.check_td12340() self.check_td12342() if self.err_case > 0: -- GitLab