You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2015/07/07 20:16:04 UTC
[jira] [Resolved] (CALCITE-280) BigDecimal underflow
[ https://issues.apache.org/jira/browse/CALCITE-280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-280.
---------------------------------
Resolution: Fixed
Fix Version/s: 1.4.0-incubating
Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/e39911ed.
I did not add a configuration parameter. I hard-coded DECIMAL64. If that is not good enough open another case.
> BigDecimal underflow
> --------------------
>
> Key: CALCITE-280
> URL: https://issues.apache.org/jira/browse/CALCITE-280
> Project: Calcite
> Issue Type: Bug
> Reporter: GitHub Import
> Assignee: Julian Hyde
> Labels: github-import
> Fix For: 1.4.0-incubating
>
>
> avg() on BigDecimal column hits SqlFunctions.divide(BigDeciaml, BigDecimal), which further calls BigDecimal.divide(BigDecimal). This method will throw exception when the result has infinite digits after the decimal point, e.g. 10/9=1.11111...
> The stack is as follows:
> {noformat}
> java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
> at java.math.BigDecimal.divide(BigDecimal.java:1690)
> at org.apache.calcite.runtime.SqlFunctions.divide(SqlFunctions.java:547)
> at Baz$5$1.current(Unknown Source)
> at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:685)
> at org.apache.calcite.avatica.util.IteratorCursor.next(IteratorCursor.java:48)
> at org.apache.calcite.avatica.AvaticaResultSet.next(AvaticaResultSet.java:215)
> at sqlline.IncrementalRows.hasNext(IncrementalRows.java:62)
> at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
> at sqlline.SqlLine.print(SqlLine.java:1652)
> at sqlline.Commands.execute(Commands.java:833)
> at sqlline.Commands.sql(Commands.java:732)
> at sqlline.SqlLine.dispatch(SqlLine.java:807)
> at sqlline.SqlLine.begin(SqlLine.java:681)
> at sqlline.SqlLine.start(SqlLine.java:398)
> at sqlline.SqlLine.main(SqlLine.java:292)
> {noformat}
> Alternatively, divide(BigDecimal divisor, MathContext mc) should be called instead, so BigDecimal knows the precision and rounding mode to handle the infinite number.
> ---------------- Imported from GitHub ----------------
> Url: https://github.com/julianhyde/optiq/issues/280
> Created by: [liyang-gmt8|https://github.com/liyang-gmt8]
> Labels:
> Created at: Mon May 12 10:25:07 CEST 2014
> State: open
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)