#28523·presto

Order INNER join filter conjuncts: ON-clause equalities should run before pushed-down post-join predicates

Author: kaikalurCreated Sep 21, 2026Updated Sep 21, 2026

For a join shaped like

sql
SELECT ...
FROM a JOIN b ON k1 = k2 AND IF(v1 = v2, TRUE, FALSE)
WHERE p(x, y, z);

the resulting INNER join filter evaluates the post-join predicate p(x, y, z) (pushed down from the WHERE clause) before the ON-clause equality IF(v1 = v2, TRUE, FALSE).

Expected: cheap equalities from the ON clause run first, and p(x, y, z) runs after everything else. Join filters short-circuit left to right, so burying a selective equality behind an expensive pushed-down expression wastes per-pair CPU in the join.

Mechanism: PredicatePushDown.processInnerJoin appends the inherited post-join conjuncts to the join filter ahead of the original ON-clause non-equi conjuncts, and nothing re-orders the merged filter by cost/selectivity afterwards.