Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-25434

Throw an error when BigDecimal precision overflows.

    XMLWordPrintableJSON

Details

    Description

       

      Lost a lot of data but no error was thrown.

      As the following comment, If the precision overflows, null will be returned.

      /**
       If the precision overflows, null will be returned.
       */
      public static @Nullable DecimalData fromBigDecimal(BigDecimal bd, int precision, int scale) {
          bd = bd.setScale(scale, RoundingMode.HALF_UP);
          if (bd.precision() > precision) {
              return null;
          }
      
          long longVal = -1;
          if (precision <= MAX_COMPACT_PRECISION) {
              longVal = bd.movePointRight(scale).longValueExact();
          }
          return new DecimalData(precision, scale, longVal, bd);
      } 

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ana4 Luning Wang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: