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

Codegen compile error when implementing unary minus function with data type BigDecimal

    XMLWordPrintableJSON

Details

    Description

      case:

        @Test public void test() throws Exception {
          final String cr = "create table t (a DECIMAL)";
          final String se = "select -a as aa from t";
          Connection c = connect();
          Statement s = c.createStatement();
          s.execute(cr);
          s.executeQuery(se);
        }
      

      error msg: 

      Caused by: org.codehaus.commons.compiler.CompileException: Line 21, Column 71: Object of type "java.math.BigDecimal" cannot be converted to a numeric type
      
      public Object current() {
      final java.math.BigDecimal current = inputEnumerator.current() == null ? (java.math.BigDecimal) null : org.apache.calcite.runtime.SqlFunctions.toBigDecimal(inputEnumerator.current());
      return current == null ? (java.math.BigDecimal) null : - current;
      }
      

      `- current` is not right ,we'd better constructor a new BigDecimal object to to replace this code snippet,like 

      return current == null ? (java.math.BigDecimal) null : SqlFunctions.negativeDecimal(current);
      

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hhlai1990 Lai Zhou
              Votes:
              0 Vote for this issue
              Watchers:
              7 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 - 8h 10m
                  8h 10m