[
https://issues.apache.org/jira/browse/CALCITE-6191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17803980#comment-17803980
]
Julian Hyde commented on CALCITE-6191:
--------------------------------------
I think you’re actually converting the Join into a Project.
if there’s a Project after the Join the rule doesn’t need to worry about it -
ProjectMergeRule will deal with it later.
This pattern comes up in Morel. “from e in emp, one in[1], doubleSal in[e.sal *
2]” is equivalent to “from e in emp yield \{e.empno, e.sal, one = 1, doubleSal
= e.sal * 2}”.
> Remove join if input is one row literal
> ---------------------------------------
>
> Key: CALCITE-6191
> URL: https://issues.apache.org/jira/browse/CALCITE-6191
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Jiajun Xie
> Assignee: Jiajun Xie
> Priority: Minor
>
> Here are some Join Rules
> {noformat}
> at CoreRules.java | grep ' #JOIN_'
> * @see #JOIN_REDUCE_EXPRESSIONS
> * @see #JOIN_SUB_QUERY_TO_CORRELATE */
> * @see #JOIN_SUB_QUERY_TO_CORRELATE */
> * @see #JOIN_TO_SEMI_JOIN */
> /** As {@link #JOIN_COMMUTE} but swaps outer joins as well as inner joins.
> */
> /** As {@link #JOIN_PROJECT_BOTH_TRANSPOSE} but only the left input is
> /** As {@link #JOIN_PROJECT_BOTH_TRANSPOSE} but only the right input is
> /** As {@link #JOIN_PROJECT_BOTH_TRANSPOSE} but match outer as well as
> /** As {@link #JOIN_PROJECT_LEFT_TRANSPOSE} but match outer as well as
> /** As {@link #JOIN_PROJECT_RIGHT_TRANSPOSE} but match outer as well as
> * @see #JOIN_TO_MULTI_JOIN
> {noformat}
> I cannot optimize the SQL by using them.
> {noformat}
> SELECT EMPNO FROM emp, (SELECT 1 as c) temp WHERE EMPNO = temp.c{noformat}
> Here is optimized RelNode that I want get.
> {code:java}
> LogicalProject(EMPNO=[$0])
> LogicalFilter(condition=[=($0, 1)])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]]){code}
> But now it is
> {noformat}
> LogicalProject(EMPNO=[$0])
> LogicalFilter(condition=[=($0, $9)])
> LogicalJoin(condition=[true], joinType=[inner])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> LogicalValues(tuples=[[{ 1 }]]){noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)