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

incorrect timezone handling for java.sql.Time #2020

Open
peterhalicky opened this issue Jan 8, 2025 · 3 comments
Open

incorrect timezone handling for java.sql.Time #2020

peterhalicky opened this issue Jan 8, 2025 · 3 comments
Assignees
Labels
question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage

Comments

@peterhalicky
Copy link

peterhalicky commented Jan 8, 2025

  1. What version of JDBC driver are you using?
    3.21.0

  2. What operating system and processor architecture are you using?
    MacOS 15.2, Apple Silicon (ARM)

  3. What version of Java are you using?
    openjdk 21.0.5 (temurin)

  4. What did you do?

Create a table with a TIME column, insert a row with value 12:34:56. My local timezone is UTC+1, snowflake is in UTC.
See: https://github.com/peterhalicky/snowflake-jdbc-time-bug

  1. What did you expect to see?

I expect that when I query the row and use ResultSet.getTime on the column, I get the same value. But instead I got 11:34:56. I suspect this is a problem in the JDBC driver, since snowflake as such doesn't really carry timezone in the TIME column. I would expect that PreparedStatement.setTime() and ResultSet.getTime() are consistent when converting to/from java.sql.Time.

  1. Can you set logging to DEBUG and collect the logs?

Attached.
snowflake_jdbc0.log

@peterhalicky
Copy link
Author

Note that the problem seems to be on insert (i.e. PreparedStatement.setTime()); when I inspect the table contents at app.snowflake.com (the web interface), it's showing 11:34:56.

@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jan 9, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added question Issue is a usage/other question rather than a bug status-triage Issue is under initial triage status-information_needed Additional information is required from the reporter and removed bug labels Jan 9, 2025
@sfc-gh-dszmolka
Copy link
Contributor

hi there - thanks for raising this issue.
Can you please check the repro from my colleague in #1805 (comment) ?
I suspect what you're seeing is dependent on current values of JDBC_USE_SESSION_TIMEZONE and TIMEZONE in the session.

@peterhalicky
Copy link
Author

Yes, it is very likely dependent on a variety of timezone related settings. I did not touch neither one of the values in my tests, so it is using whatever defaults are in place. In #1805 the time value is sent as a literal in the SQL statement. My tests and observations indicate that the problem is when passing a java.sql.Time value into a PreparedStatement. Regardless of the scenario and timezone configuration, I would expect that the conversions are consistent with each other -- my test shows that they're not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

2 participants