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

Muhammad Gelbana edited comment on CALCITE-1792 at 5/22/17 10:00 AM:
---------------------------------------------------------------------

[~julianhyde], why would you support the FALSE literal ? I'm working on 
supporting cartesian and inner joins for Drill and I had to do why you did. I 
modified the 
org.apache.calcite.adapter.jdbc.JdbcRules.JdbcJoin.implement(JdbcImplementor) 
implementation to be 
{code:java}
public JdbcImplementor.Result implement(JdbcImplementor implementor) {
        final JdbcImplementor.Result leftResult = implementor.visitChild(0, 
left);
        final JdbcImplementor.Result rightResult = implementor.visitChild(1, 
right);

        final JdbcImplementor.Context leftContext = 
leftResult.qualifiedContext();
        final JdbcImplementor.Context rightContext = 
rightResult.qualifiedContext();

        SqlNode sqlCondition = null;
        JoinConditionType joinCondition = JoinConditionType.NONE;
        JoinType joinType = JoinType.COMMA;

        if (leftContext != null && rightContext != null) {
            sqlCondition = convertConditionToSqlNode(condition, leftContext, 
rightContext, left.getRowType().getFieldCount());
            if (sqlCondition != null) {
                joinType = JoinType.INNER;
                joinCondition = JoinConditionType.ON;
            }
        }

        SqlJoin join = new SqlJoin(POS, leftResult.asFrom(), 
SqlLiteral.createBoolean(false, POS), joinType.symbol(POS),
                    rightResult.asFrom(), joinCondition.symbol(POS), 
sqlCondition);
        return implementor.result(join, leftResult, rightResult);
}
{code}

And the convertConditionToSqlNode method to accept RexLiteral
{code:java}
if (!(node instanceof RexCall) && !(node instanceof RexLiteral)) {
        throw new AssertionError(node);
}
{code}

and added a Literal case
{code:java}
case LITERAL:
        RexLiteral literal = (RexLiteral) node;
        if (literal.isAlwaysTrue()) {
            return null;
        }
        break;
{code}


was (Author: mgelbana):
[~julianhyde], why would you support the FALSE literal ? I'm working on 
supporting cartesian and inner joins for Drill and I had to do why you did. I 
modified the 
org.apache.calcite.adapter.jdbc.JdbcRules.JdbcJoin.implement(JdbcImplementor) 
implementation to be 


> RelToSqlConverter doesn't handle cartesian join (join cond as TRUE)
> -------------------------------------------------------------------
>
>                 Key: CALCITE-1792
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1792
>             Project: Calcite
>          Issue Type: Bug
>          Components: jdbc-adapter
>            Reporter: Sergiy Simonov
>            Assignee: Jess Balint
>            Priority: Minor
>             Fix For: 1.13.0
>
>
> this test fails (added in {{RelToSqlConverterTest}}):
> {code}
>     @Test public void testCartesianProductWithFullJoinSyntax() {
>     String query = "select * from \"department\"\n"
>             + "FULL JOIN \"employee\" ON TRUE";
>     String expected = "SELECT *\nFROM \"foodmart\".\"department\"\n"
>             + "FULL JOIN \"foodmart\".\"employee\" ON TRUE";
>     sql(query).ok(expected);
>   }
> {code}
> {{RelToSqlConverter}} is checking that the join condition is a {{RexCall}}. 
> In this case (and {{RelBuilder.join()}} with no join cond), the join cond is 
> a {{RexLiteral}} with a value of {{true}}.
> Suggested fix is to handle the case with this specific join condition before 
> {{convertConditionToSqlNode()}}:



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to