Repository navigation
Preserve nanoseconds when binding TIMESTAMP_NS parameters - #948
Open
hutiefang76 wants to merge 2 commits into
Open
hutiefang76 wants to merge 2 commits into
hutiefang76 wants to merge 2 commits into
Conversation
Keep Timestamp and LocalDateTime nanoseconds through typed prepared parameters and JNI, including Calendar bindings. Preserve the existing microsecond conversions for other parameter types, and reject values that overflow the nanosecond range or coincide with infinity sentinels. Add round-trip, boundary and compatibility regressions, and update the existing Appender comparison that expected the old precision loss. AI-assisted implementation and review using Codex and DeepSeek.
The startup JNI cache loads DuckDBTimestampNS even for ordinary queries. Register its class and getNanosEpoch method, and exercise Timestamp and LocalDateTime nanosecond binds in the existing native-image smoke test. Generated-by: Codex and DeepSeek V4 Flash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #571.
Binding
2026-02-20 12:00:00.123456789to aTIMESTAMP_NSparameter currently stores.123456000. Keep the exact epoch nanoseconds through the Java/JNI parameter conversion forTimestampandLocalDateTime, including the Calendar timestamp overload. Literal reads already preserve nanoseconds; the new insert/read round trips exercise the affected binding path.The conversion checks overflow and the native infinity sentinels without changing ordinary TIMESTAMP/TIMESTAMPTZ bindings or the default type of untyped parameters. Tests cover negative fractions, Calendar zones, NULL, finite bounds, rejected values and the wider microsecond date range. The existing Appender comparison is updated only where its prepared-statement row expected the old precision loss.
Validation on macOS arm64, JDK 21.0.10:
make releaseandmake test: passed, 589 distinct test methods, no failures.make format-checkpassed with clang-format 11.0.1.AI assistance: Codex and DeepSeek assisted with investigation, implementation, tests and review. The native build and test results above were executed locally. The previous head passed 13 CI jobs but failed the Graal native runtime smoke test because the new JNI class lacked reachability metadata. This follow-up registers it and extends that smoke test with nanosecond binding assertions. CI for the updated head remains to be verified.
Graal follow-up validation:
NoClassDefFoundError: org/duckdb/DuckDBTimestampNS; changing only the JAR’s JNI reachability metadata makes the same final smoke test pass, including exact123456789nanoseconds forsetTimestampandsetObject(LocalDateTime).make release,make test(589 distinct test methods) and official clang-format 11.0.1make format-checkpassed again on macOS arm64.