You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!
What version of JDBC driver are you using?
3.13.30 and 3.13.31
What operating system and processor architecture are you using?
macOS, arm64
What version of Java are you using?
openjdk version "17.0.5" 2022-10-18
What did you do?
Connection conn = getConnection();
Statement stmt = conn.createStatement();
stmt.executeQuery("ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'");
stmt.executeQuery("CREATE OR REPLACE TABLE TEST_TIME(TIME_COL TIME)");
stmt.executeQuery("INSERT INTO TEST_TIME VALUES ('12:34:56.123456789')");
ResultSet rs = stmt.executeQuery("SELECT * FROM TEST_TIME");
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println(rsmd.getColumnClassName(1));
while (rs.next()) {
System.out.println(rs.getObject(1).getClass());
System.out.println(((SnowflakeTimeWithTimezone)rs.getObject(1)).getNano());
System.out.println(rs.getTime(1));
}
rs.close();
stmt.close();
conn.close();
What did you expect to see?
In 3.13.0, this returns
java.sql.Time
class net.snowflake.client.jdbc.SnowflakeTimeWithTimezone
123456789
12:34:56
While in 3.13.1
This returns
java.sql.Time
class java.sql.Time
Exception in thread "main" java.lang.ClassCastException: class java.sql.Time cannot be cast to class net.snowflake.client.jdbc.SnowflakeTimeWithTimezone (java.sql.Time is in module java.sql of loader 'platform'; net.snowflake.client.jdbc.SnowflakeTimeWithTimezone is in unnamed module of loader 'app')
at io.animesh.snowflake.SnowflakeExample.issueCode(SnowflakeExample.java:43)
at io.animesh.snowflake.SnowflakeExample.main(SnowflakeExample.java:29)
What this means is now instead of SnowflakeTimeWithTimezone which contained info about nanos, java.sql.Time is being used, which on the other hand only stores upto seconds granularity.
github-actionsbot
changed the title
getTime losing nanosecond values from 3.13.31
SNOW-1714049: getTime losing nanosecond values from 3.13.31
Oct 4, 2024
@akanimesh7 sorry for the delay in getting back to you on this.
Yes, there was a change, but that's on purpose to address a different issue, and the new behavior you're seeing is the expected outcome. The getTime() method is supposed to strictly return a data type of java.sql.Time which is why the getObject() is returning what you're seeing given that the column in Snowflake is of type TIME. As you pointed out, java.sql.Time doesn't store nanoseconds, so if you need to preserve nanoseconds then you should use getTimestamp() instead. That will return java.sql.Timestamp which has nanoseconds precision.
Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!
3.13.30 and 3.13.31
What operating system and processor architecture are you using?
macOS, arm64
What version of Java are you using?
openjdk version "17.0.5" 2022-10-18
What did you do?
In 3.13.0, this returns
While in 3.13.1
This returns
What this means is now instead of
SnowflakeTimeWithTimezone
which contained info about nanos,java.sql.Time
is being used, which on the other hand only stores upto seconds granularity.The reason for this seems to be this PR -- #1383
The text was updated successfully, but these errors were encountered: