-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
api: spannerIssues related to the googleapis/java-spanner-jdbc API.Issues related to the googleapis/java-spanner-jdbc API.
Description
Environment details
- OS type and version: Microsoft Windows [Version 10.0.26100.6584]
- Java version: openjdk version "21.0.2" 2024-01-16 LTS
- version(s):
com.google.cloud:google-cloud-spanner-jdbc:2.33.0
Steps to reproduce
Read a FLOAT64
Infinity
value as Java float
value
Code example
Consider this reproducer:
```java
try (
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("select cast('Infinity' as float32), cast('Infinity' as float64)")
) {
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getDouble(1));
System.out.println(rs.getFloat(1));
System.out.println(rs.getString(2));
System.out.println(rs.getDouble(2));
System.out.println(rs.getFloat(2));
}
}
It prints:
Infinity
Infinity
Infinity
Infinity
Infinity
com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory$JdbcSqlExceptionImpl: OUT_OF_RANGE: Value out of range for float: Infinity
at com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.of(JdbcSqlExceptionFactory.java:247)
at com.google.cloud.spanner.jdbc.AbstractJdbcWrapper.checkedCastToFloat(AbstractJdbcWrapper.java:295)
at com.google.cloud.spanner.jdbc.JdbcResultSet.getFloat(JdbcResultSet.java:467)
at org.jooq.testscripts.JDBC.main(JDBC.java:49)
Java itself doesn't have this issue. Both types' infinities can be cast to the other type correctly:
jshell> (double) Float.POSITIVE_INFINITY
$1 ==> Infinity
jshell> (float) Double.POSITIVE_INFINITY
$2 ==> Infinity
Stack trace
com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory$JdbcSqlExceptionImpl: OUT_OF_RANGE: Value out of range for float: Infinity
at com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.of(JdbcSqlExceptionFactory.java:247)
at com.google.cloud.spanner.jdbc.AbstractJdbcWrapper.checkedCastToFloat(AbstractJdbcWrapper.java:295)
at com.google.cloud.spanner.jdbc.JdbcResultSet.getFloat(JdbcResultSet.java:467)
at org.jooq.testscripts.JDBC.main(JDBC.java:49)
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/java-spanner-jdbc API.Issues related to the googleapis/java-spanner-jdbc API.