Hi Corvin,

Transforming an outer join to an inner join is usually a good thing in
terms of performance. Inner joins have more efficient implementation
algorithms than outer joins and they are also easier to reorder when you
have multiple joins in the query.

Such transformation should kick-in only when the transformation is
equivalent (conditions/metadata guarantee that nullable columns don't
matter). If a transformation leads to wrong results, errors, or some other
problem then we are talking about a bug; if that's the case please log a
JIRA issue.

Benchao gave some pointers on how you could affect this behavior but the
question is why do you want to disable this optimization?

Best,
Stamatis


On Mon, Apr 11, 2022, 1:59 PM Benchao Li <[email protected]> wrote:

> Hi Kuebler,
>
> This is an optimization in FilterJoinRule[1], and yes, it can be
> configured.
>
> [1]
>
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java#L91
>
> Kuebler, Corvin <[email protected]> 于2022年4月11日周一 19:47写道:
>
> > Hi @Caclite Devs,
> >
> > I recently started working with calcite and stumbled upon some join
> > optimization behavior that looks strange to me.
> > I was fiddling around with a filtered join on a Jdbc-Datasource:
> >
> > ```SQL
> > SELECT f.name, b. name
> > FROM foo f,
> > RIGHT JOIN bar b,
> > ON f.id = b. id
> > WHERE b.property NOT IN (‘’)
> > ```
> >
> > As I inspected the outcomes of this query it became obvious that calcite
> > seems to “forget” about the join type in the query. No matter if left or
> > right join the resulting physical plan always resulted in an inner join.
> >
> > This led me to taking a closer look at the source code and I discovered
> > the logic in
> >
> https://github.com/apache/calcite/blob/de48e55783a140e6927f88a445d9cbdf2e7623b5/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java#L2772
> > ff.
> > It seems that the above behavior is intended and cannot be configured out
> > as the parameter to do so should not be set to false in production (
> >
> https://github.com/apache/calcite/blob/de48e55783a140e6927f88a445d9cbdf2e7623b5/core/src/main/java/org/apache/calcite/rel/rules/CoreRules.java#L239
> > ).
> >
> > Is there any chance you could explain to me why one would want to ignore
> > the join type and filter out null columns? Is there any way to disable
> this
> > behavior?
> >
> > Thanks in advance.
> >
> > Bests regards,
> > Corvin Kübler
> >
> >
>
> --
>
> Best,
> Benchao Li
>

Reply via email to