diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 3367c4a36acc33413fae256290ddc5926f2720e3..874a022a7104860fce8f6389bcc933b36a2fef22 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4928,7 +4928,11 @@ int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaI } } - pse->colInfo.flag = pSource->base.colInfo.flag; //TSDB_COL_NORMAL; + if (!pQueryInfo->stableQuery && TSDB_COL_IS_TAG(pSource->base.colInfo.flag)) { + pse->colInfo.flag = (pSource->base.colInfo.flag) & (~TSDB_COL_TAG); + } else { + pse->colInfo.flag = pSource->base.colInfo.flag; + } pse->resType = pSource->base.resType; pse->resBytes = pSource->base.resBytes; strncpy(pse->colInfo.name, pSource->base.aliasName, tListLen(pse->colInfo.name)); diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index 195eca928fa4ddbf3795ae3e40f973ea0a5e8def..258b59f4ae5ffd75878bca469efc226a6d2d0825 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -956,4 +956,39 @@ sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group #sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; #sql select count(*),tbname from select_tags_mt0 group by tbname +print ==================================> TD-11943 +sql create database test11943; +sql use test11943; +sql create stable st (ts timestamp , id int ) tags (ind int ); +sql insert into sub1 using st tags(1) values(now ,1); +sql insert into sub1 using st tags(1) values(now ,2); +sql insert into sub2 using st tags(2) values(now ,3); +sql insert into sub2 using st tags(2) values(now ,4); +sql select tbname ,max(id)+5 from sub1; +if $data00 != @sub1@ then + return -1 +endi +if $data01 != @7.000000000@ then + return -1 +endi +sql select ind, max(id)+5 from st group by tbname +if $data00 != @1@ then + return -1 +endi +if $data01 != @7.000000000@ then + return -1 +endi +if $data02 != @sub1@ then + return -1 +endi +if $data10 != @2@ then + return -1 +endi +if $data11 != @9.000000000@ then + return -1 +endi +if $data12 != @sub2@ then + return -1 +endi +sql drop database test11943 system sh/exec.sh -n dnode1 -s stop -x SIGINT