Uploaded image for project: 'Zeppelin'
  1. Zeppelin
  2. ZEPPELIN-1434

Long numbers rounding in Zeppelin-Web table

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      zeppelin-web is using Handsontable package to generate the table view within the notebooks' paragraphs.
      In the paragraph controller, within the Handsontable object instantiation, the cells function checks if the given value is a number (using !isNan(value) method). If the value is indeed a number, it will render as follows:

      else if (!isNaN(value)) {
          cellProperties.format = '0,0.[00000]';
          td.style.textAlign = 'left';
          Handsontable.renderers.NumericRenderer.apply(this, arguments);
      }
      

      Since javascript supports numbers between -(2^53^ - 1) and (2^53^ - 1), any number not within this range, will be rounded (up or down) and wrong numbers will be shown. I suggest to add another condition to check whether the number is a safe number:

      Number.isSafeInteger(parseInt(value))
      

      In that case, just render the value as a string (no formatting).

      The second issue is with very small floats. The current rendering will only show up to 5 decimal places. There should be another condition to check if the value is a float, and if so use parseFloat or Number(value) to render it with the e notation:

      function isFloat(a) {
        return a.indexOf('.') !== -1;
      }
      ...
      if (isFloat(value)) {
          parseFloat(value);
      }
      

      Attachments

        Activity

          People

            meenakshi.chandrasekar@imaginea.com Meenakshi
            davidtzoor David Tzoor
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: