fix: join condition with single param operator

This commit is contained in:
dapan1121 2023-09-12 19:18:43 +08:00
parent ef7eb478e4
commit dd1457e49c
2 changed files with 13 additions and 1 deletions

View File

@ -812,7 +812,7 @@ static bool pushDownCondOptIsColEqualOnCond(SJoinLogicNode* pJoin, SNode* pCond,
return false; return false;
} }
SOperatorNode* pOper = (SOperatorNode*)pCond; SOperatorNode* pOper = (SOperatorNode*)pCond;
if (QUERY_NODE_COLUMN != nodeType(pOper->pLeft) || QUERY_NODE_COLUMN != nodeType(pOper->pRight)) { if (QUERY_NODE_COLUMN != nodeType(pOper->pLeft) || NULL == pOper->pRight || QUERY_NODE_COLUMN != nodeType(pOper->pRight)) {
return false; return false;
} }
SColumnNode* pLeft = (SColumnNode*)(pOper->pLeft); SColumnNode* pLeft = (SColumnNode*)(pOper->pLeft);

View File

@ -112,6 +112,18 @@ class TDTestCase:
tdSql.query(f"select a.* from sta a join stb b on a.tg1 != b.tg1 and a.ts=b.ts;") tdSql.query(f"select a.* from sta a join stb b on a.tg1 != b.tg1 and a.ts=b.ts;")
tdSql.checkRows(36) tdSql.checkRows(36)
tdSql.query(f"select a.* from sta a join stb b on a.ts=b.ts and a.ts is null;")
tdSql.checkRows(0)
tdSql.query(f"select a.* from sta a join stb b on a.ts=b.ts and a.ts is not null;")
tdSql.checkRows(48)
tdSql.query(f"select a.* from sta a ,stb b where a.ts=b.ts and a.ts is null;")
tdSql.checkRows(0)
tdSql.query(f"select a.* from sta a ,stb b where a.ts=b.ts and a.ts is not null;")
tdSql.checkRows(48)
# tdSql.checkData(0,1,10) # tdSql.checkData(0,1,10)
tdSql.error(f"select a.* from sta a join stb b on a.tg1=b.tg1 where a.ts=b.ts or a.tg2=b.tg2;") tdSql.error(f"select a.* from sta a join stb b on a.tg1=b.tg1 where a.ts=b.ts or a.tg2=b.tg2;")