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

Throw an error when BigDecimal precision overflows.

Agile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment