[fix](planner)fix bug of bound conjunct to wrong tuple (#28811)

this fix bug introduced by #28656
This commit is contained in:
starocean999
2023-12-21 19:15:36 +08:00
committed by GitHub
parent 4f1aebb8e8
commit a16680cf91
2 changed files with 9 additions and 3 deletions

View File

@ -1335,12 +1335,12 @@ public class Analyzer {
public void registerConjuncts(Expr e, boolean fromHavingClause, List<TupleId> ids) throws AnalysisException {
for (Expr conjunct : e.getConjuncts()) {
registerConjunct(conjunct);
if (!e.isConstant()) {
if (!conjunct.isConstant()) {
ArrayList<TupleId> tupleIds = Lists.newArrayList();
ArrayList<SlotId> slotIds = Lists.newArrayList();
e.getIds(tupleIds, slotIds);
conjunct.getIds(tupleIds, slotIds);
if (tupleIds.isEmpty() && slotIds.isEmpty()) {
e.setBoundTupleIds(ids);
conjunct.setBoundTupleIds(ids);
}
}
if (ids != null) {

View File

@ -32,5 +32,11 @@ suite("test_rand_filter") {
sql("""select * from test_rand_filter_t where rand() < 0.5 union all select * from test_rand_filter_t where rand() > 0.3;""")
notContains("AND")
}
explain {
sql("""select * from test_rand_filter_t
union all (select * from test_rand_filter_t where rand() < 0.3)
union all (select * from test_rand_filter_t where a > 5 and rand() < 0.4);""")
notContains("rand() < 0.3 AND rand() < 0.4")
}
sql """ DROP TABLE IF EXISTS test_rand_filter_t """
}