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

EXTRACT function's SQL return type is BIGINT but implemented as Java int

    Details

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

      Description

      1. The return type of EXTRACT_DATE is BIGINT (i.e. long) after parsing.
      ```
      public SqlExtractFunction()

      { super( "EXTRACT", SqlKind.OTHER_FUNCTION, ReturnTypes.BIGINT_NULLABLE, null, OperandTypes.INTERVALINTERVAL_INTERVALDATETIME, SqlFunctionCategory.SYSTEM); }

      ```

      2. The return type of SqlFunctions.unixDateExtract is Integer.
      ```
      public net.hydromatic.linq4j.Enumerable bind(final net.hydromatic.optiq.DataContext root0) {
      final net.hydromatic.linq4j.AbstractEnumerable child = new net.hydromatic.linq4j.AbstractEnumerable(){
      public net.hydromatic.linq4j.Enumerator enumerator() {
      return new net.hydromatic.linq4j.Enumerator(){
      ... ...
      public Object current()

      { return net.hydromatic.optiq.runtime.SqlFunctions.unixDateExtract(net.hydromatic.optiq.runtime.SqlFunctions.TimeUnitRange.YEAR, net.hydromatic.optiq.runtime.SqlFunctions.toInt(((Object[]) inputEnumerator.current())[2])); }

      };
      }
      };
      ```

      3. BIGINT will be treat as Long that is conflict with Integer.
      ```
      java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
      at net.hydromatic.optiq.runtime.AbstractCursor$LongAccessor.getLong(AbstractCursor.java:469)
      at net.hydromatic.optiq.runtime.AbstractCursor$ExactNumericAccessor.getBigDecimal(AbstractCursor.java:365)
      at net.hydromatic.avatica.AvaticaResultSet.getBigDecimal(AvaticaResultSet.java:352)
      at org.dbunit.dataset.datatype.BigIntegerDataType.getSqlValue(BigIntegerDataType.java:100)
      at org.dbunit.database.ForwardOnlyResultSetTable.getValue(ForwardOnlyResultSetTable.java:104)
      at org.dbunit.dataset.DefaultTable.addTableRows(DefaultTable.java:139)
      at org.dbunit.database.CachedResultSetTable.<init>(CachedResultSetTable.java:69)
      at org.dbunit.database.CachedResultSetTableFactory.createTable(CachedResultSetTableFactory.java:52)
      ```

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/281
      Created by: jiangxuchina
      Labels:
      Created at: Tue May 13 09:35:13 CEST 2014
      State: closed

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            github-import GitHub Import
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development