You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jesus Camacho Rodriguez (JIRA)" <ji...@apache.org> on 2017/02/27 19:59:46 UTC

[jira] [Comment Edited] (CALCITE-1661) Recognize aggregation function types as FRACTIONAL instead of DOUBLE

    [ https://issues.apache.org/jira/browse/CALCITE-1661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15886420#comment-15886420 ] 

Jesus Camacho Rodriguez edited comment on CALCITE-1661 at 2/27/17 7:58 PM:
---------------------------------------------------------------------------

You are right, that is fair. Rounding might happen. Overflowing might happen too, though I do not know if there is a deterministic behavior to handle it, e.g., defined by the SQL standard.

That is why I think we should check the precision&scale and act accordingly, e.g., if DECIMAL with given precision&scale can be represented as double without loss of precision, we store it in Druid and thus we can push the aggregation; otherwise, we do not. That would work for COUNT, SUM, MIN, and MAX aggregation functions that we currently support. In addition, it plays nicely with the recognition of LONG vs DOUBLE aggregation function in Druid?

[~ashutoshc], what do you think? [~julianhyde], could you give your opinion about this too? Maybe I am missing something... If you agree this is fine, I will update the PR accordingly.


was (Author: jcamachorodriguez):
You are right, that is fair. Rounding might happen. Overflowing might happen too, though I do not know if there is a deterministic behavior to handle it, e.g., defined by the SQL standard.

That is why I think we should check the precision&scale and act accordingly, e.g., if DECIMAL with given precision&scale can be represented as double without loss of precision, we store it in Druid and thus we can push the aggregation; otherwise, we do not. That would work for COUNT, SUM, MIN, and MAX aggregation functions that we currently support. In addition, it plays nicely with the recognition of LONG vs DOUBLE aggregation function in Druid?

[~ashutoshc], what do you think? [~julianhyde], could you give your opinion about this too? Maybe I am missing something...

> Recognize aggregation function types as FRACTIONAL instead of DOUBLE
> --------------------------------------------------------------------
>
>                 Key: CALCITE-1661
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1661
>             Project: Calcite
>          Issue Type: Bug
>          Components: druid
>    Affects Versions: 1.12.0
>            Reporter: Jesus Camacho Rodriguez
>            Assignee: Jesus Camacho Rodriguez
>             Fix For: 1.12.0
>
>
> Currently, whether to use fractional or integer aggregations is based on following code (L699 in DruidQuery.java).
> {code}
> final boolean b = aggCall.getType().getSqlTypeName() == SqlTypeName.DOUBLE;
> {code}
> Since Hive might use other fractional types for the aggregation, we might end up using the wrong type of aggregation in Druid. We could extend the check as follows:
> {code}
> final boolean b = SqlTypeName.FRACTIONAL_TYPES.contains(aggCall.getType().getSqlTypeName());
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)