osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Created] (CALCITE-2606) Return type inference for and/or may identify result type incorrectly


Zoltan Haindrich created CALCITE-2606:
-----------------------------------------

             Summary: Return type inference for and/or may identify result type incorrectly
                 Key: CALCITE-2606
                 URL: https://issues.apache.org/jira/browse/CALCITE-2606
             Project: Calcite
          Issue Type: Bug
            Reporter: Zoltan Haindrich
            Assignee: Zoltan Haindrich


In case in an AND expression a null constant appears earlier than a nullable boolean; the return type is set to NULL instead of boolean.

https://github.com/apache/calcite/blob/c39bfaa02a06ac91575076a6e74f29863923f5eb/core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java#L198

The problem can be reproduced; however I'm not sure if it would happen naturally or not - I've discovered it during enhancing case simplification.

{code}
  @Test
  public void testUsageOfConstantNull() {
    RexLiteral constantNull = rexBuilder.constantNull();

    RexNode node1 = or(constantNull, vBool());
    assertThat(node1.getType(), is(vBool().getType()));

    RexNode node2 = or(vBoolNotNull(), constantNull);
    assertThat(node2.getType(), is(vBool().getType()));

    RexNode node3 = or(constantNull, constantNull);
    assertThat(node3.getType(), is(constantNull.getType()));
  }
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)