[
https://issues.apache.org/jira/browse/PHOENIX-6741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17560845#comment-17560845
]
chaijunjie commented on PHOENIX-6741:
-------------------------------------
I think it should use the last real maxLength in *DivideExpression* class, not
get from the *getPrecision* method?
!file:///C:/Users/c00580863/AppData/Roaming/eSpace_Desktop/UserData/c00580863/imagefiles/DFE15238-10F7-4ADD-B42A-630A598C86F9.png|id=DFE15238-10F7-4ADD-B42A-630A598C86F9,vspace=3!
> The result of DivideExpression is wrong when two decimal number divide
> ----------------------------------------------------------------------
>
> Key: PHOENIX-6741
> URL: https://issues.apache.org/jira/browse/PHOENIX-6741
> Project: Phoenix
> Issue Type: Bug
> Components: core
> Affects Versions: 5.1.2
> Reporter: chaijunjie
> Assignee: chaijunjie
> Priority: Major
> Attachments: code.PNG
>
>
> When two number has same precision and scale, then the result will be scaled
> by 0.
> DROP TABLE IF EXISTS TEST;
> CREATE TABLE TEST (
> ID INTEGER NOT NULL PRIMARY KEY,
> A DECIMAL(18,10),
> B DECIMAL(18,10)
> );
> UPSERT INTO TEST VALUES(1,100,200);
> SELECT ID,A/B AS C FROM TEST;
> 0: jdbc:phoenix:> SELECT ID,A/B AS C FROM TEST;
> +-----+----+
> | ID | C |
> +-----+----+
> | 1 | 0 |
> +-----+----+
> But, we need a precise result, so we need add a 1.00*, then the result will
> be right.
> 0: jdbc:phoenix:> SELECT ID,1.00*A/B AS C FROM TEST;
> +-----+------+
> | ID | C |
> +-----+------+
> | 1 | 0.5 |
> +-----+------+
--
This message was sent by Atlassian Jira
(v8.20.10#820010)