-
Notifications
You must be signed in to change notification settings - Fork 51
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.7171]
- Java version: openjdk version "21.0.7" 2025-04-15 LTS
- version(s): I'm working with the spanner emulator: https://github.com/GoogleCloudPlatform/cloud-spanner-emulator and JDBC driver version:
com.google.cloud:google-cloud-spanner-jdbc:2.34.0
Steps to reproduce
Read a NUMERIC value using ResultSet::getLong
Code example
try (
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("select cast(1 as numeric)")
) {
while (rs.next()) {
System.out.println(rs.getLong(1));
}
}Stack trace
Exception in thread "main" java.lang.IllegalStateException: Column 0 is not of correct type: expected one of [STRING, NUMERIC] but was NUMERIC
at com.google.common.base.Preconditions.checkState(Preconditions.java:853)
at com.google.cloud.spanner.AbstractStructReader.checkNonNullOfTypes(AbstractStructReader.java:724)
at com.google.cloud.spanner.AbstractStructReader.getString(AbstractStructReader.java:238)
at com.google.cloud.spanner.connection.DirectExecuteResultSet.getString(DirectExecuteResultSet.java:224)
at com.google.cloud.spanner.jdbc.JdbcResultSet.getLong(JdbcResultSet.java:435)
at org.jooq.testscripts.JDBC.main(JDBC.java:45)
This doesn't happen when reading it using ResultSet::getInt, for example.
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/java-spanner-jdbc API.Issues related to the googleapis/java-spanner-jdbc API.