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-1723202: Support Java 8 java.time types #169

Open
DenWav opened this issue Oct 5, 2024 · 2 comments
Open

SNOW-1723202: Support Java 8 java.time types #169

DenWav opened this issue Oct 5, 2024 · 2 comments
Assignees
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team

Comments

@DenWav
Copy link

DenWav commented Oct 5, 2024

Java 8 time types are more modern and should be preferred over the old types Date, Time, etc.

  • java.time.LocalDate
  • java.time.LocalTime
  • java.time.LocalDateTime
  • java.time.OffsetDateTime
  • java.time.ZonedDateTime
  • java.time.Instant

The Snowflake documentation specifies:

Although Snowflake can store time values with nanosecond precision, the java.sql.time library maintains only millisecond precision. Conversion between Snowflake and Java data types can reduce effective precision to milliseconds.

This limitation is not present in the modern java.time types, and time zone information is explicit, rather than implicit and prone to error.

Note that proper implementation of this would not involve converting from the old Java types to the new ones, since that would not fix the issue described here.

@github-actions github-actions bot changed the title Support Java 8 java.time types SNOW-1723202: Support Java 8 java.time types Oct 5, 2024
@sfc-gh-dszmolka
Copy link

hi - i'm wondering this could be a little bit of duplicate of snowflakedb/snowflake-jdbc#1494 for the underlying Snowflake JDBC driver ?
Can you please check ?

@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jan 3, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team labels Jan 3, 2025
@DenWav
Copy link
Author

DenWav commented Jan 31, 2025

Related, and yes indeed we need that ticket for sure. I had to write a really ugly wrapper around the Snowflake JDBC driver to get around that limitation.

But no this is no a duplicate - consider the Row class, for example. There is no way to retrieve Java 8 time types from any columns. getAs(<index|name>, type) presents an API that might look like it does what we need, allowing something like:

getAs(1, LocalDateTime.class)

but that is not true. getAs only delegates to the other get methods. The API here needs to be expanded to support these types, whether or not that depends on the JDBC driver as well is an implementation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-information_needed Additional information is required from the reporter status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants