Skip to content

[Optimizer] Refactor convert join #2256

@jackwener

Description

@jackwener

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Now

explain select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0;

It can be transformed

explain select * from t1  inner join t2 on t1.c1 = t2.c2 where t1.c1 > 0;

But the implementation is a little hack and inelegant.

We can implement it in optimizer rule instead of planner build--->plan_selection

We can refactor it and do it using the other optimizer rule combine.

Describe the solution you'd like
#2255 include many rule, some rule is preconditions.

In fact, current result convert join of should be result of some rule combine instead of we rewrite plan directly in plan_selection.

Transformation path

select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0;
-- infer predicate -->
select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0 and  t2.c1 > 0;
-- convert outer join -->
select * from t1 inner join t2 on t1.c1 = t2.c2 where t1.c1 > 0 and  t2.c1 > 0;

or

select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0;
-- infer not null -->
select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0 and t1.c1 is not null;
-- infer predicate -->
select * from t1 join t2 on t1.c1 = t2.c2 where t1.c1 > 0 and t1.c1 is not null and t2.c1 > 0 and t2.c1 is not null;
-- convert outer join -->
select * from t1 inner join t2 on t1.c1 = t2.c2 where t1.c1 > 0 and t1.c1 is not null and t2.c1 > 0 and t2.c1 is not null;

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions