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

ClassCastException retrieving from an ARRAY that has DATE, TIME or TIMESTAMP elements

    XMLWordPrintableJSON

Details

    Description

      cases to reproduce

      select array[current_date];
      select array[cast('1900-1-1' as date)];
      select array[current_timestamp];
      select array[current_time];
      

      each query fails with ClassCastException mentioned below.
      It seems the reason is that date/time/timestamp could be both int/long and java_sql_*.

      class java.sql.Date cannot be cast to class java.lang.Number (java.sql.Date is in module java.sql of loader 'platform'; java.lang.Number is in module java.base of loader 'bootstrap')
      java.lang.ClassCastException: class java.sql.Date cannot be cast to class java.lang.Number (java.sql.Date is in module java.sql of loader 'platform'; java.lang.Number is in module java.base of loader 'bootstrap')
      	at org.apache.calcite.avatica.util.AbstractCursor$NumberAccessor.getNumber(AbstractCursor.java:722)
      	at org.apache.calcite.avatica.util.AbstractCursor$DateFromNumberAccessor.getString(AbstractCursor.java:928)
      	at org.apache.calcite.avatica.util.ArrayImpl.toString(ArrayImpl.java:62)
      	at org.apache.calcite.avatica.util.AbstractCursor$ArrayAccessor.getString(AbstractCursor.java:1365)
      	at org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:239)
      

      Attachments

        Issue Links

          Activity

            People

              Sergey Nuyanzin Sergey Nuyanzin
              Sergey Nuyanzin Sergey Nuyanzin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 20m
                  2h 20m