Zuozhi Wang created CALCITE-4713:
------------------------------------

             Summary: JavaTypeFactory#leastRestrictive returns wrong type for 
JavaType(String)
                 Key: CALCITE-4713
                 URL: https://issues.apache.org/jira/browse/CALCITE-4713
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.27.0
            Reporter: Zuozhi Wang


When using JavaTypeFactoryImpl, calling `leastRestrictive` with two 
`JavaType(String)` types gives a wrong return type of `VARCHAR` (SqlType). The 
expected return type should still be `JavaType(String)` 

See the following test case:
```
  @Test void testLeastRestrictiveWithWithJavaString() {
    RelDataType javaStringType = TYPE_FACTORY.createJavaType(String.class);
    // leastRestrictive of two same JavaType(String) types
    RelDataType leastRestrictive = TYPE_FACTORY.leastRestrictive(
        Arrays.asList(javaStringType, javaStringType));
    // expect leastRestrictive to also be JavaType(String)
    // but actual value is VARCHAR (BasicSqlType)
    assertEquals(javaStringType, leastRestrictive);
  }
```


We are currently investigating a fix of this issue, possibly by adding some 
equality checks.




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

Reply via email to