diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index effbbc161e465e0fac6ced24136c318ccc30d2a5..931e762a8d1f72cae54e98a6cc2d1af51ccc3aab 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2596,11 +2596,13 @@ static bool tbCntScanOptIsEligibleConds(STbCntScanOptInfo* pInfo, SNode* pCondit } if (QUERY_NODE_LOGIC_CONDITION == nodeType(pConditions)) { - return tbCntScanOptIsEligibleLogicCond(pInfo, (SLogicConditionNode*)pConditions); + return tbCntScanOptIsEligibleLogicCond(pInfo, (SLogicConditionNode*)pConditions) && + LIST_LENGTH(pInfo->pAgg->pGroupKeys) == 0; } if (QUERY_NODE_OPERATOR == nodeType(pConditions)) { - return tbCntScanOptIsEligibleOpCond((SOperatorNode*)pConditions); + return tbCntScanOptIsEligibleOpCond((SOperatorNode*)pConditions) && + LIST_LENGTH(pInfo->pAgg->pGroupKeys) == 0; } return false; diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index ac5e23273af20afb9ff223b885e54c85cdce11ef..6e65852dcc4ccab82e44fc0260227fe5709c2259 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -103,7 +103,14 @@ endi if $data62 != 5 then return -1 endi - +sql select count(table_name) from information_schema.ins_tables where db_name='db1' and stable_name='sta' group by stable_name +print $rows , $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 8 then + return -1 +endi sql select distinct db_name from information_schema.ins_tables; print $rows if $rows != 4 then