Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 2.0
-
None
Description
For decimal_v2=true, we should revisit the add/sub result type. Currently, we set result scale to max(S1, S2) (potentially losing precision). Other systems (e.g. SQL Server) seem to choose either S1 or S2 depending on whether digits to the left of the decimal point would be lost. This would require changes to the backend implementation of add/sub, however.
Currently we compute rP and rS as follows:
rS = max(s1, s2) rP = max(s1, s2) + max(p1 - s1, p2 - s2) + 1
We currently handle the case where rP > 38 as follows:
if (rP > 38):
rP = 38
rS = min(38, rS)
This basically truncates the digits to the left of the decimal point.
The proposed result under V2 is:
if (rP > 38):
minS = min(rS, 6)
rS = rS - (rP - 38)
rS = max(minS, rS)
Attachments
Issue Links
- blocks
-
IMPALA-4924 Make DECIMAL_V2 the default mode
- Resolved