You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@metamodel.apache.org by Kasper Sørensen <i....@gmail.com> on 2017/07/15 17:29:42 UTC
Re: NaN / Infinity values
Looking at this, it seems like it's a JDBC driver bug. At least the
conversion from Object to BigDecimal seems to happen in org.postgresql.jdbc.
PgResultSet when I look at the stack trace. So I would suggest either
raising the issue with the PostgreSQL people - but first of all I'd try to
upgrade the driver to the latest version if you don't already have that.
2017-07-15 8:35 GMT-07:00 Dana Borger <Da...@sas.com>:
>
>
> Postgres, for example, allows NaN and infinity values on numeric columns
> (with some exclusions).
>
>
>
> When we try read these, we get:
>
>
>
> org.apache.metamodel.MetaModelException: Could not get next record in
> resultset: Bad value for type BigDecimal : NaN
>
> at org.apache.metamodel.jdbc.JdbcUtils.wrapException(
> JdbcUtils.java:61)
>
> at org.apache.metamodel.jdbc.JdbcDataSet.next(JdbcDataSet.
> java:141)
>
>
>
> . . .
>
>
>
> Caused by: org.postgresql.util.PSQLException: Bad value for type
> BigDecimal : NaN
>
> at org.postgresql.jdbc.PgResultSet.toBigDecimal(
> PgResultSet.java:2880)
>
> at org.postgresql.jdbc.PgResultSet.toBigDecimal(
> PgResultSet.java:2889)
>
> at org.postgresql.jdbc.PgResultSet.getBigDecimal(
> PgResultSet.java:2332)
>
> at org.postgresql.jdbc.PgResultSet.internalGetObject(
> PgResultSet.java:192)
>
> at org.postgresql.jdbc.PgResultSet.getObject(
> PgResultSet.java:2571)
>
> at org.apache.metamodel.jdbc.dialects.AbstractQueryRewriter.
> getResultSetValue(AbstractQueryRewriter.java:461)
>
>
>
> In our previous code, we would try these as BigDecimal, and if a SQL
> exception occurred, we would retry it with *ResultSet.getDouble()* which
> works because Double supports both Nan and Infinite values.
>
>
>
> Can you suggest a work-around or fix? We have thought of a couple, but
> because database vendors differ in their support for NaN and Infinite
> values, none of them are very appealing.
>
>
>
> Best,
>
> Dana
>
>
>