I just discovered that queries containing left joins aren't rewritten when materializations are available and wondered why that is a limitation. I looked a bit into the implementation and found out that org.apache.calcite.rel.metadata.RelMdAllPredicates#getAllPredicates(org.apache.calcite.rel.core.Join, org.apache.calcite.rel.metadata.RelMetadataQuery) returns null when encountering a non-inner join.

For an inner join, the method returns essentially the join predicate, so I thought a left join should be similar. How about returning an OR node that asserts input refs of "outer-joined" tables are null if unmatched?

Let's consider an example query like "from emp e left join dept d on e.deptno = d.deptno"

If the join were an inner join, the return would be "=(e.deptno, d.deptno)". In case of a left join I'd suppose it returns "OR(IS_NULL(d.deptno),=(e.deptno, d.deptno))". Would that be sufficient to implement left join support or do you have something different in mind? I couldn't find a ticket for that particular case to discuss a possible implementation so please direct me if you already tracked that issue.

--

Mit freundlichen Grüßen,
------------------------------------------------------------------------
*Christian Beikov*

Reply via email to