[
https://issues.apache.org/jira/browse/CALCITE-280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde updated CALCITE-280:
--------------------------------
Description:
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
was:
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...
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
> BigDecimal underflow
> --------------------
>
> Key: CALCITE-280
> URL: https://issues.apache.org/jira/browse/CALCITE-280
> Project: Calcite
> Issue Type: Bug
> Reporter: GitHub Import
> Labels: github-import
>
> 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)