[
https://issues.apache.org/jira/browse/PHOENIX-1075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14059652#comment-14059652
]
Hudson commented on PHOENIX-1075:
---------------------------------
SUCCESS: Integrated in Phoenix | 3.0 | Hadoop1 #132 (See
[https://builds.apache.org/job/Phoenix-3.0-hadoop1/132/])
PHOENIX-1075 Mathematical order of operations are improperly evaluated. (Kyle
Buzsaki) (anoopsamjohn: rev 92aceb3674a7b1511d7660583e51407f08c60117)
* phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java
* phoenix-core/src/main/antlr3/PhoenixSQL.g
> Mathematical order of operations are improperly evaluated.
> ----------------------------------------------------------
>
> Key: PHOENIX-1075
> URL: https://issues.apache.org/jira/browse/PHOENIX-1075
> Project: Phoenix
> Issue Type: Bug
> Reporter: Kyle Buzsaki
> Assignee: Kyle Buzsaki
> Fix For: 5.0.0, 3.1, 4.1
>
> Attachments: PHOENIX-1075.patch, PHOENIX-1075_2.patch
>
>
> The root of the issue is that, as things are now, multiplication and division
> don't actually have the same precedence in the grammar. Division is always
> grouped more tightly than multiplication and is evaluated first. Most of the
> time, this doesn't matter, but combined with the truncating integer division
> used by LongDivideExpression it produces some unexpected and probably wrong
> behavior. Below is an example:
> Expression: 6 * 4 / 3
> Evaluating left to right, this should reduce as follows:
> 6 * 4 / 3
> 24 / 3
> 8
> As phoenix is now, division has a higher precedence than multiplication.
> Therefore, the resulting expression tree looks like this:
> !http://i.imgur.com/2Zzsfpy.png!
> Because integer division in truncating, when the division evaluates the
> expression tree looks like this:
> !http://i.imgur.com/3cLGD0e.png!
> Which then evaluates to 6.
--
This message was sent by Atlassian JIRA
(v6.2#6252)