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

Feng Zhu commented on CALCITE-3435:
-----------------------------------

After investigate some materials, it seems that many products follow the rule 
in MS-SQL^[1][2][3][4]^.
{code:java}
e1[s1, p1] % e2[s2, p2]

s = max(s1, s2)
p = min(p1-s1, p2-s2) + max(s1, s2){code}
Therefore, I open a PR to implement the logic. Could you take a look when you 
have time?

[1] MS-SQL: https://msdn.microsoft.com/en-us/library/ms190476.aspx
[2] Apache Hive: 
https://cwiki.apache.org/confluence/download/attachments/27362075/Hive_Decimal_Precision_Scale_Support.pdf
[3] Apache Spark: 
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecision.scala
[4] Impala: https://impala.apache.org/docs/build/html/topics/impala_decimal.html

> floor(mod(33.5,7)) wrongly returns 5.5
> --------------------------------------
>
>                 Key: CALCITE-3435
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3435
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.16.0, 1.21.0
>            Reporter: jiezouSH
>            Assignee: Feng Zhu
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> mod's return type is
> chain(DECIMAL_MOD_NULLABLE, ARG1_NULLABLE),
> but mod(33.5,7)'s result is 5.5, not in line with ARG1_NULLABLE.
> This causes floor(mod(33.5,7)) wrongly returns 5.5



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to