David Tzoor created ZEPPELIN-1434:
-------------------------------------
Summary: Long numbers rounding in Zeppelin-Web table
Key: ZEPPELIN-1434
URL: https://issues.apache.org/jira/browse/ZEPPELIN-1434
Project: Zeppelin
Issue Type: Bug
Reporter: David Tzoor
Priority: Critical
zeppelin-web is using {{Handsontable}} package to generate the table view
within the notebooks' paragraphs.
In the [paragraph
controller|https://github.com/apache/zeppelin/blob/master/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js],
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:
{code:javascript}
else if (!isNaN(value)) {
cellProperties.format = '0,0.[00000]';
td.style.textAlign = 'left';
Handsontable.renderers.NumericRenderer.apply(this, arguments);
}
{code}
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:
{code:javascript}
Number.isSafeInteger(parseInt(value))
{code}
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:
{code:javascript}
function isFloat(a) {
return a.indexOf('.') !== -1;
}
...
if (isFloat(value)) {
parseFloat(value);
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)