Skip to content

Commit b68cde0

Browse files
committed
Precision loss in numeric datatypes
1 parent d63b1fb commit b68cde0

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

docs/machine-learning/known-issues-for-sql-server-machine-learning-services.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Known issues for Python and R
33
description: This article describes known problems or limitations with the Python and R components that are provided in SQL Server Machine Learning Services and SQL Server 2016 R Services.
44
ms.prod: sql
55
ms.technology: machine-learning-services
6-
ms.date: 07/07/2020
6+
ms.date: 07/14/2020
77
ms.topic: troubleshooting
88
author: dphansen
99
ms.author: davidph
@@ -528,6 +528,14 @@ SQL Server 2019 contains a regression that effects R scripts that use parallel e
528528

529529
**Applies to:** SQL Server 2019.
530530

531+
### 23. Precision loss for money/numeric/decimal/bigint data types
532+
533+
Executing an R script with `sp_execute_external_scripts` allows money, numeric, decimal, and bigint data types as input data. However, because they are converted to float internally, they suffer a precision loss with values that are very high or have decimal point values.
534+
535+
+ **money**: Sometimes cent values would be imprecise and a warning would be issued: *Warning: unable to precisely represent cents values*.
536+
+ **numeric/decimal**: `sp_execute_external_scripts` with an R script does not support the full range of those data types and would alter the last few decimal digits especially those with fraction.
537+
+ **bigint**: R only support up to 53-bit integers and then it will start to have precision loss.
538+
531539
## Python script execution issues
532540

533541
This section contains known issues that are specific to running Python on SQL Server, as well as issues that are related to the Python packages published by Microsoft, including [revoscalepy](https://docs.microsoft.com/r-server/python-reference/revoscalepy/revoscalepy-package) and [microsoftml](https://docs.microsoft.com/r-server/python-reference/microsoftml/microsoftml-package).

docs/machine-learning/r/r-libraries-and-data-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ The following table shows the changes in data types and values when data from [!
3535

3636
|SQL type|R class|RESULT SET type|Comments|
3737
|-|-|-|-|
38-
|**bigint**|`numeric`|**float**||
38+
|**bigint**|`numeric`|**float**|Executing an R script with `sp_execute_external_scripts` allows bigint data type as input data. However, because they are converted to float internally, it suffers a precision loss with values that are very high or have decimal point values. R only support up to 53-bit integers and then it will start to have precision loss.|
3939
|**binary(n)**<br /><br /> n <= 8000|`raw`|**varbinary(max)**|Only allowed as input parameter and output|
4040
|**bit**|`logical`|**bit**||
4141
|**char(n)**<br /><br /> n <= 8000|`factor`|**varchar(max)**||
4242
|**datetime**|`POSIXct`|**datetime**|Represented as GMT|
4343
|**date**|`POSIXct`|**datetime**|Represented as GMT|
44-
|**decimal(p,s)**|`numeric`|**float**||
44+
|**decimal(p,s)**|`numeric`|**float**|Executing an R script with `sp_execute_external_scripts` allows decimal data type as input data. However, because they are converted to float internally, it suffers a precision loss with values that are very high or have decimal point values. `sp_execute_external_scripts` with an R script does not support the full range of the data type and would alter the last few decimal digits especially those with fraction.|
4545
|**float**|`numeric`|**float**||
4646
|**int**|`integer`|**int**||
47-
|**money**|`numeric`|**float**||
48-
|**numeric(p,s)**|`numeric`|**float**||
47+
|**money**|`numeric`|**float**|Executing an R script with `sp_execute_external_scripts` allows money data type as input data. However, because they are converted to float internally, it suffers a precision loss with values that are very high or have decimal point values. Sometimes cent values would be imprecise and a warning would be issued: *Warning: unable to precisely represent cents values*. |
48+
|**numeric(p,s)**|`numeric`|**float**|Executing an R script with `sp_execute_external_scripts` allows numeric data type as input data. However, because they are converted to float internally, it suffers a precision loss with values that are very high or have decimal point values. `sp_execute_external_scripts` with an R script does not support the full range of the data type and would alter the last few decimal digits especially those with fraction.|
4949
|**real**|`numeric`|**float**||
5050
|**smalldatetime**|`POSIXct`|**datetime**|Represented as GMT|
5151
|**smallint**|`integer`|**int**||

0 commit comments

Comments
 (0)