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

RexBuilder may lose decimal fraction for creating literal with DECIMAL type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.22.0
    • None

    Description

      this test

      // RexBuilderTest
      @Test public void testDecimal() {
      final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
      final RelDataType type = typeFactory.createSqlType(SqlTypeName.DECIMAL, 4, 2);
      final RexBuilder builder = new RexBuilder(typeFactory);
      final RexLiteral literal = (RexLiteral) builder.makeLiteral(12.3, type, false);
      Comparable value = literal.getValue();
      assertThat(value.toString(), is("12.3"));
      }
      

      fails with message

      java.lang.AssertionError: 
      Expected: is "12.3"
           but: was "12"
      Expected :12.3
      Actual   :12
      

      Attachments

        Issue Links

          Activity

            People

              yanlin-Lynn Wang Yanlin
              yanlin-Lynn Wang Yanlin
              Votes:
              0 Vote for this issue
              Watchers:
              6 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 - 50m
                  50m