Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5653

Extract(year) from SQL Server date and datetime2 types fail with ClassCastException: org.apache.calcite.avatica.util.TimeUnitRange

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.10.0
    • None
    • Storage - JDBC
    • None
    • Drill 1.10
      SQL Server 2016

    Description

      plugin defined to SQL Server 2016 via JDBC

      select TDT.RNUM, extract( year from TDT.CDT ) from certsqlserver.dbo.TDT

      SYSTEM ERROR: ClassCastException: org.apache.calcite.avatica.util.TimeUnitRange cannot be cast to org.apache.calcite.sql.SqlLiteral$SqlSymbol

      select TTS.RNUM, extract( year from TTS.CTS ) from certsqlserver.dbo.TTS

      SYSTEM ERROR: ClassCastException: org.apache.calcite.avatica.util.TimeUnitRange cannot be cast to org.apache.calcite.sql.SqlLiteral$SqlSymbol

      SQL Server DLL

      create table "TDT" ( "RNUM" integer not null , "CDT" date );
      go

      grant select on "TDT" to public;
      go

      insert into "TDT"("RNUM", "CDT") values ( 0, NULL);
      go

      insert into "TDT"("RNUM", "CDT") values ( 1, '1996-01-01');
      go

      insert into "TDT"("RNUM", "CDT") values ( 2, '2000-01-01');
      go

      insert into "TDT"("RNUM", "CDT") values ( 3, '2000-12-31');
      go

      create table "TTS" ( "RNUM" integer not null , "CTS" datetime2(3 ) );
      go

      grant select on "TTS" to public;
      go

      insert into "TTS"("RNUM", "CTS") values ( 0, NULL);
      go

      insert into "TTS"("RNUM", "CTS") values ( 1, '1996-01-01 00:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 2, '1996-01-01 12:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 3, '1996-01-01 23:59:30.123000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 4, '2000-01-01 00:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 5, '2000-01-01 12:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 6, '2000-01-01 23:59:30.123000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 7, '2000-12-31 00:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 8, '2000-12-31 12:00:00.000000000');
      go

      insert into "TTS"("RNUM", "CTS") values ( 9, '2000-12-31 12:15:30.123000000');
      go

      Attachments

        Activity

          People

            Unassigned Unassigned
            the6campbells N Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: