fix: condition shouldn't pushdown as subquery has limit clause

This commit is contained in:
facetosea 2025-03-10 10:22:22 +08:00
parent 42b7c9fb12
commit ff06947468
2 changed files with 18 additions and 2 deletions

View File

@ -2112,12 +2112,15 @@ static int32_t pdcDealProject(SOptimizeContext* pCxt, SProjectLogicNode* pProjec
if (NULL != pProject->node.pLimit || NULL != pProject->node.pSlimit) {
return TSDB_CODE_SUCCESS;
}
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0);
if(pChild->pLimit != NULL) {
return TSDB_CODE_SUCCESS;
}
int32_t code = TSDB_CODE_SUCCESS;
SNode* pProjCond = NULL;
code = rewriteProjectCondForPushDown(pCxt, pProject, &pProjCond);
if (TSDB_CODE_SUCCESS == code) {
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0);
code = pdcPushDownCondToChild(pCxt, pChild, &pProjCond);
}

View File

@ -360,7 +360,19 @@ class TDTestCase:
tdSql.checkRows(0)
tdLog.info("check db1 vgroups 1 limit 1 offset 100 successfully!")
def ts6080(self):
tdLog.printNoPrefix("======== test case 6080: ")
tdSql.execute("create database db6080 vgroups 1;")
tdSql.execute("use db6080;")
tdSql.execute("create table db6080.st(ts timestamp, age int) tags(area int);")
tdSql.execute("create table db6080.t1 using db6080.st tags(1);")
tdSql.Execute("insert into db6080.t1 values(1537146000000, 1);")
tdSql.Execute("insert into db6080.t1 values(1537146000001, 2);")
tdSql.query("select ts, age from (select ts, age from db6080.t1 order by ts limit 1) where ts > 1537146000000;")
tdSql.checkRows(0)
def run(self):
# tdSql.prepare()
self.prepareTestEnv()
@ -368,6 +380,7 @@ class TDTestCase:
# one vgroup diff more than one vgroup check
self.checkVGroups()
def stop(self):