[ 
https://issues.apache.org/jira/browse/CALCITE-6966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945738#comment-17945738
 ] 

Julian Hyde commented on CALCITE-6966:
--------------------------------------

It didn't help that I didn't understand the name 'JoinOrExpansionRule' - I 
thought it did either joins or expansion. 'JoinExpandOrToUnionRule' might have 
been better. Note that it uses 'expand' as a verb, rather than 'expansion' as a 
noun.

Look, I know it's frustrating when you produce good code and I harp on about 
Jira cases and commit messages. But most users of Calcite read the release 
notes (which link to Jira cases) and don't read the code. So the Jira case must 
describe the purpose of the change, well enough that another developer could go 
and implement that change.

In other words, we need contributors to write specifications. Because if you 
don't, in a couple of years the code will be a mess, and will be worthless.

By the way, I saw your javadoc in JoinOrExpansionRule.java. It looks really 
good but without 'pre' tags the formatting will be destroyed when the javadoc 
is rendered.

> Extend JoinConditionOrExpansionRule to support column and constants as valid 
> conditions
> ---------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6966
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6966
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Zhen Chen
>            Assignee: Zhen Chen
>            Priority: Major
>              Labels: pull-request-available
>
> SQL:
> {code:java}
> select * from emp as t1 inner join emp as t2
> on (t1.empno=t2.empno
>    and t1.empno > 100
>    and t1.ename in ('a', 'bb', 'cc')
>    and t1.sal > 120 and t1.sal < 3000)
>    or
>    (t1.deptno=t2.deptno
>    and t2.empno > 200
>    and t2.ename in ('a', 'bb', 'cc')
>    and t2.sal > 110 and t2.sal < 3000) {code}
> Init plan:
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$9], ENAME0=[$10], 
> JOB0=[$11], MGR0=[$12], HIREDATE0=[$13], SAL0=[$14], COMM0=[$15], 
> DEPTNO0=[$16], SLACKER0=[$17])
>   LogicalJoin(condition=[OR(AND(=($0, $9), >($0, 100), SEARCH($1, 
> Sarg['a':VARCHAR(20), 'bb':VARCHAR(20), 'cc':VARCHAR(20)]:VARCHAR(20)), 
> SEARCH($5, Sarg[(120..3000)])), AND(=($7, $16), >($9, 200), SEARCH($10, 
> Sarg['a':VARCHAR(20), 'bb':VARCHAR(20), 'cc':VARCHAR(20)]:VARCHAR(20)), 
> SEARCH($14, Sarg[(110..3000)])))], joinType=[inner])
>     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}
> can convert to:
> {code:java}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
> SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$9], ENAME0=[$10], 
> JOB0=[$11], MGR0=[$12], HIREDATE0=[$13], SAL0=[$14], COMM0=[$15], 
> DEPTNO0=[$16], SLACKER0=[$17])
>   LogicalUnion(all=[true])
>     LogicalJoin(condition=[AND(=($0, $9), >($0, 100), SEARCH($1, 
> Sarg['a':VARCHAR(20), 'bb':VARCHAR(20), 'cc':VARCHAR(20)]:VARCHAR(20)), 
> SEARCH($5, Sarg[(120..3000)]))], joinType=[inner])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>     LogicalJoin(condition=[AND(=($7, $16), >($9, 200), SEARCH($10, 
> Sarg['a':VARCHAR(20), 'bb':VARCHAR(20), 'cc':VARCHAR(20)]:VARCHAR(20)), 
> SEARCH($14, Sarg[(110..3000)]), OR(<>($0, $9), <=($0, 100), SEARCH($1, 
> Sarg[(-∞..'a':VARCHAR(20)), ('a':VARCHAR(20)..'bb':VARCHAR(20)), 
> ('bb':VARCHAR(20)..'cc':VARCHAR(20)), ('cc':VARCHAR(20)..+∞)]:VARCHAR(20)), 
> SEARCH($5, Sarg[(-∞..120], [3000..+∞)])))], joinType=[inner])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>       LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to