duckdb: [Java] Regression in conversion of Long to Timestamp value via appender
What happens?
In 0.3.3, DuckDBAppender.append(long) could be used to append a millisecond value to be converted to a timestamp in the resulting table.
As of 0.4.0, appending the value fails with an exception:
Not implemented Error: Unimplemented type for cast (INT64 -> TIMESTAMP)
java.sql.SQLException: Not implemented Error: Unimplemented type for cast (INT64 -> TIMESTAMP)
at org.duckdb.DuckDBNative.duckdb_jdbc_appender_append_long(Native Method)
at org.duckdb.DuckDBAppender.append(DuckDBAppender.java:47)
To Reproduce
In 0.4.0 the test fails with the above error, but in 0.3.3 it passes successfully.
TimeZone currentTimeZone = TimeZone.getDefault();
try {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
DuckDBConnection connection = getConnection();
executeOnConnection(connection, "CREATE TABLE ts_test(ts_value timestamp)");
Instant instant = Instant.now().truncatedTo(ChronoUnit.MILLIS);
try (DuckDBAppender appender = connection.createAppender("main", "ts_test")) {
appender.beginRow();
appender.append(instant.toEpochMilli() * 1000);
appender.endRow();
}
Statement resultStatement = connection.createStatement();
ResultSet resultSet = resultStatement.executeQuery( "SELECT ts_value from ts_test");
resultSet.next();
Timestamp appendedTimestamp = resultSet.getTimestamp(1);
assertEquals(instant.toEpochMilli(), appendedTimestamp.toInstant().toEpochMilli());
resultSet.close();
resultStatement.close();
connection.close();
} finally {
// return timezone back to default.
TimeZone.setDefault(currentTimeZone);
}
Environment (please complete the following information):
- OS: Mac OS X (Apple Silicon)
- DuckDB Version: 0.4.0
- DuckDB Client: JDBC
Identity Disclosure:
- Full Name: Jonathan Swenson
- Affiliation: Omni
Before Submitting
- Have you tried this on the latest
masterbranch? - Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (5 by maintainers)
Any workaround for inserting timestamps through the appender?
0.6.1is returning the following error when trying to insert the time as microseconds doubleThat sounds good to me.
It would not need to be restricted only to the Appender, but indeed these classes might not be used for anything else in the JDBC. Accepting Java classes seems like a good idea regardless.