foxtail463 opened a new pull request, #62527:
URL: https://github.com/apache/doris/pull/62527
### What problem does this PR solve?
Problem Summary:
Extra-join elimination rejected some safe LEFT JOIN rewrites too early. Even
when the right side was guaranteed unique and the join could be eliminated
safely, the presence of right-side otherJoinConjuncts made the logic treat the
join as non-eliminable.
Example of the valid LEFT JOIN case:
-- MV
SELECT t1.id, t1.name
FROM t1
LEFT JOIN t2
ON t1.id = t2.id AND t2.id = 1
-- Query
SELECT id, name FROM t1
Here, the extra predicate `t2.id = 1` only affects whether the right side
matches.
It does not filter out rows from `t1`.
So if the right side is unique on the join key, eliminating `t2` is still
safe.
Example of the unsafe INNER JOIN case that we still reject:
-- MV
SELECT o.o_orderkey, o.o_custkey
FROM orders o
INNER JOIN lineitem l
ON o.o_orderkey = l.l_orderkey
WHERE l.l_shipdate = '2024-01-01'
-- Query
SELECT o_orderkey, o_custkey FROM orders
This is not equivalent.
The filter on `lineitem` decides which `orders` rows survive the inner join.
So if we eliminate `lineitem`, we would silently lose that filtering
semantics.
That is why the code keeps the filter-edge guard for the INNER JOIN + PK/FK
path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]