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

James Starr commented on CALCITE-4210:
--------------------------------------

[~julianhyde]
 * I don't think it makes sense to split 'createJoinCondition' into 3 methods 
'createJoinNatural', 'createJoinUsing' etc. It obscures the fact that USING and 
NATURAL are just short-hands for ON, and that, once you have derived a 
condition, all of the syntaxes are essentially the same. By splitting the 
methods you have created an opportunity for code to drift over time.
 ** {color:#4c9aff}So on an expanded subquery, it is not exactly the same for 
except for the condition because the expanded sub query needs to be attached to 
either right or the left node.  Would it be better to just inline the above 
listed functions?  Then parsing the ON condition could return a tuple of the 
modified rel node + conditional and it could mutate the relevant rel node in 
convertJoin.  I do not think we can escape have 4 branch that returns condition 
+ 1 or more rel nodes.  Alternatively, the sub functions could build the 
conditional for natural and using case, and then the createJoin could be called 
in the convertJoin() function.{color}
 * Could inner class be static?
 ** {color:#4c9aff}Yes{color}
 * Could {{blackboardRegisterArgsList}} be final?
 ** {color:#4c9aff}No, I currently mutate it on line 2872, though I could 
rework it{color}
 * I have no comment on whether you have fixed the algorithm; it confuses me.

> Sub Query is 'On' clause does not correctly expand in SqlToRelConverter
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-4210
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4210
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: James Starr
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Aggregation is dropped during decorreleation.
> {code:java}
> SELECT "employee"."department_id", "employee"."salary"
> FROM "department"
> LEFT JOIN "employee" ON "employee"."salary" = (
>   SELECT max("employee"."salary")
>   FROM "employee"
>   WHERE  "employee"."department_id" = "department"."department_id"
> )
> {code}
> {code:java}
> LogicalProject(department_id=[$9], salary=[$13])
>   LogicalJoin(condition=[=($13, $0)], joinType=[left])
>     LogicalTableScan(table=[[foodmart, department]])
>     LogicalTableScan(table=[[foodmart, employee]]){code}
> This may be related to CALCITE-4206.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to