Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1714049: getTime losing nanosecond values from 3.13.31 #1908

Open
akanimesh7 opened this issue Oct 4, 2024 · 1 comment
Open

SNOW-1714049: getTime losing nanosecond values from 3.13.31 #1908

akanimesh7 opened this issue Oct 4, 2024 · 1 comment
Assignees
Labels
bug status-triage Issue is under initial triage

Comments

@akanimesh7
Copy link

akanimesh7 commented Oct 4, 2024

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of JDBC driver are you using?

3.13.30 and 3.13.31

  1. What operating system and processor architecture are you using?
    macOS, arm64

  2. What version of Java are you using?
    openjdk version "17.0.5" 2022-10-18

  3. 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();
  1. 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.

The reason for this seems to be this PR -- #1383

@akanimesh7 akanimesh7 added the bug label Oct 4, 2024
@github-actions github-actions bot changed the title getTime losing nanosecond values from 3.13.31 SNOW-1714049: getTime losing nanosecond values from 3.13.31 Oct 4, 2024
@sfc-gh-wfateem sfc-gh-wfateem self-assigned this Oct 4, 2024
@sfc-gh-wfateem sfc-gh-wfateem added the status-triage Issue is under initial triage label Oct 4, 2024
@akanimesh7
Copy link
Author

@sfc-gh-wfateem Any updates on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

2 participants