Mihai Budiu created CALCITE-7741:
------------------------------------

             Summary: Outer join register incorrect types for their input 
collections
                 Key: CALCITE-7741
                 URL: https://issues.apache.org/jira/browse/CALCITE-7741
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.42.0
            Reporter: Mihai Budiu
            Assignee: Mihai Budiu


A LEFT join will produce nullable output fields for all fields that come from 
the RIGHT input, even if the right input does not have nullable fields. This is 
correct.

However, a LEFT join in Calcite will register a nullable types for the fields 
of the right INPUT in the Rel tree. That is wrong: the output fields of the 
join are nullable, but the input field types should not change just because 
they are part of a join.

As a concrete example, consider the following query:
{code:java}
select e.ename, d.name from emp as e
left join dept as d on trim(d.name) = 'x {code}
If you check the type of the TRIM function call in the Rel tree, it is 
nullable, although its argument is not nullable. Type inference for TRIM 
produces a non-nullable type.

This is the plan after Sql2Rel containing the TRIM expression:
{code:java}
LogicalProject(ENAME=[$1], NAME=[$10])
  LogicalJoin(condition=[=(TRIM(FLAG(BOTH), ' ', $10), 'x')], joinType=[left])
    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
    LogicalTableScan(table=[[CATALOG, SALES, DEPT]]) {code}
 



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

Reply via email to