Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-898

Type of 'Java<Long> * INTEGER' should be BIGINT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Component/s: None
    • Labels:
      None

      Description

      As discussed on the mailinglist, there seems to be a bug related to unexpected casting of Long to Integer.

      Queries such as these result in a ClassCastException.

      select EMPNO * 3 as EMPNO from EMPS where EMPNO = 100
      
      java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
      	at org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:485)
      	at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:338)
      	at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:381)
      

      I was able to reproduce the problem with the CsvTest, see attached patch. Note that, in the patch, I changed the datatype of EMPNO from int to long and that I use resultSet.getObject in stead of resultSet.getString to output the result set. With getString it works because it doesn't try to cast the Long to an Integer first.

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Type of 'Java<Long> * INTEGER' should be BIGINT; currently because JavaType(long) has unspecified precision, INTEGER is incorrectly regarded as the 'larger' type.

        In expressions with mixed Java and SQL types, we should convert to SQL types.

        Show
        julianhyde Julian Hyde added a comment - Type of 'Java<Long> * INTEGER' should be BIGINT; currently because JavaType(long) has unspecified precision, INTEGER is incorrectly regarded as the 'larger' type. In expressions with mixed Java and SQL types, we should convert to SQL types.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/0cb2e275 .
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.5.0 (2015-11-10)

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.5.0 (2015-11-10)

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            janvanbesien Jan Van Besien
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development