Merge pull request #22673 from taosdata/fix/TS-3883
fix: aggregate function omitted issue
This commit is contained in:
commit
6a24e2cdc5
|
@ -202,9 +202,25 @@ static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SIsUselessColCtx {
|
||||||
|
bool isUseless;
|
||||||
|
} SIsUselessColCtx ;
|
||||||
|
|
||||||
|
EDealRes checkUselessCol(SNode *pNode, void *pContext) {
|
||||||
|
SIsUselessColCtx *ctx = (SIsUselessColCtx *)pContext;
|
||||||
|
if (QUERY_NODE_FUNCTION == nodeType(pNode) && !fmIsScalarFunc(((SFunctionNode*)pNode)->funcId) &&
|
||||||
|
!fmIsPseudoColumnFunc(((SFunctionNode*)pNode)->funcId)) {
|
||||||
|
ctx->isUseless = false;
|
||||||
|
return DEAL_RES_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isUselessCol(SExprNode* pProj) {
|
static bool isUselessCol(SExprNode* pProj) {
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pProj) && !fmIsScalarFunc(((SFunctionNode*)pProj)->funcId) &&
|
SIsUselessColCtx ctx = {.isUseless = true};
|
||||||
!fmIsPseudoColumnFunc(((SFunctionNode*)pProj)->funcId)) {
|
nodesWalkExpr((SNode*)pProj, checkUselessCol, (void *)&ctx);
|
||||||
|
if (!ctx.isUseless) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return NULL == ((SExprNode*)pProj)->pAssociation;
|
return NULL == ((SExprNode*)pProj)->pAssociation;
|
||||||
|
|
|
@ -6082,8 +6082,18 @@ class TDTestCase:
|
||||||
tdLog.info(len(sql))
|
tdLog.info(len(sql))
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
|
|
||||||
#special sql
|
#6
|
||||||
tdSql.query("select 6-1 from stable_1;")
|
tdSql.query("select 6-1 from stable_1;")
|
||||||
|
for i in range(self.fornum):
|
||||||
|
sql = "select count(*) from (select avg(q_int)/1000 from stable_1); "
|
||||||
|
tdLog.info(sql)
|
||||||
|
tdLog.info(len(sql))
|
||||||
|
tdSql.query(sql)
|
||||||
|
self.cur1.execute(sql)
|
||||||
|
self.explain_sql(sql)
|
||||||
|
|
||||||
|
#special sql
|
||||||
|
tdSql.query("select 7-1 from stable_1;")
|
||||||
for i in range(self.fornum):
|
for i in range(self.fornum):
|
||||||
sql = "select * from ( select _block_dist() from stable_1);"
|
sql = "select * from ( select _block_dist() from stable_1);"
|
||||||
tdSql.error(sql)
|
tdSql.error(sql)
|
||||||
|
|
Loading…
Reference in New Issue