Merge pull request #23514 from taosdata/szhou/3.0/fix/TD-27089

fix: tag scan mode when no columns after const optimization
This commit is contained in:
dapan1121 2023-11-07 15:13:52 +08:00 committed by GitHub
commit 51f1798474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -285,7 +285,7 @@ static SNode* createConstantValue() {
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
SNode* pProj = NULL;
WHERE_EACH(pProj, pSelect->pProjectionList) {
if (subquery && !pSelect->isDistinct && isUselessCol((SExprNode*)pProj)) {
if (subquery && !pSelect->isDistinct && !pSelect->tagScan && isUselessCol((SExprNode*)pProj)) {
ERASE_NODE(pSelect->pProjectionList);
continue;
}

View File

@ -140,4 +140,28 @@ if $data01 != @1aa@ then
return -1
endi
sql create table stb34 (ts timestamp, f int) tags(t int);
sql insert into ctb34 using stb34 tags(1) values(now, 1)(now+1s, 2);
sql select 1 from (select tags t from stb34 order by t)
print $rows
if $rows != 1 then
return -1
endi
sql select count(*) from (select tags t from stb34)
if $data00 != 1 then
return -1
endi
sql select 1 from (select tags ts from stb34)
print $rows
if $rows != 2 then
return -1
endi
sql select count(*) from (select tags ts from stb34)
if $data00 != 2 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT