[
https://issues.apache.org/jira/browse/PHOENIX-2536?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15308735#comment-15308735
]
Sergey Soldatov commented on PHOENIX-2536:
------------------------------------------
[~kliew] Thanks for the clarification. I'm aware about it. Actually Those are
two different cases. And the SQL Standard quote is related to SUM aggregation
function (so, it's applicable to PHOENIX-1708), but not dyadic arithmetical
operators that are in the description. For the dyadic operators following rules
should be applied:
{noformat}
1) If the data type of both operands of a dyadic arithmetic opera-
tor is exact numeric, then the data type of the result is exact
numeric, with precision and scale determined as follows:
a) Let S1 and S2 be the scale of the first and second operands
respectively.
b) The precision of the result of addition and subtraction is
implementation-defined, and the scale is the maximum of S1
and S2.
c) The precision of the result of multiplication is implementation-
defined, and the scale is S1 + S2.
d) The precision and scale of the result of division is
implementation-defined.
2) If the data type of either operand of a dyadic arithmetic op-
erator is approximate numeric, then the data type of the re-
sult is approximate numeric. The precision of the result is
implementation-defined.
{noformat}
> Return of aggregation functions do not have the correct data type and
> precision
> -------------------------------------------------------------------------------
>
> Key: PHOENIX-2536
> URL: https://issues.apache.org/jira/browse/PHOENIX-2536
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.6.0
> Reporter: Kevin Liew
> Assignee: Sergey Soldatov
> Labels: function, phoenix
> Fix For: 4.8.0
>
>
> ANSI SQL specifies that
> {quote}If SUM is specified and DT is exact numeric with scale
> S, then the data type of the result is exact numeric with
> implementation-defined precision and scale S.
> ...
> If DT is approximate numeric, then the data type of the
> result is approximate numeric with implementation-defined
> precision not less than the precision of DT.{quote}
> However, when summing integer types (first operand) with float or double
> (second operand), Phoenix returns the value with the same data type as the
> first operand.
> Doing a sum with the first operand being a FLOAT or DOUBLE will return a
> DECIMAL with a fixed scale of 4.
> Doing any multiplication or division will also result in a DECIMAL with scale
> 4.
> In all of the cases outlined above, the return data type does not meet the
> ANSI standard.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)