Repository navigation
fix: decode signed timestamp nanoseconds and truncate to the requested unit - #93
Open
ahed-jneed wants to merge 1 commit into
Open
ahed-jneed wants to merge 1 commit into
ahed-jneed wants to merge 1 commit into
Conversation
The Apache ORC C++ writer stores the negative fraction of a pre-1970 timestamp as is (pyarrow writes 1969-07-20 20:17:40.5 as -14182939 seconds and -500000000 nanoseconds). decode cast the nanoseconds to u64, so undoing the trailing-zero encoding overflowed: debug builds panicked and release builds failed the whole file. Decode them as signed, as the C++ reader does, and do the arithmetic in i128 so no input can overflow it. decode_timestamp also refused any value with digits below the requested unit, so a single nanosecond value failed a read at microsecond precision. Truncate toward zero instead, matching Arrow's cast between timestamp units; a value that overflows i64 still fails.
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.
Problem
The Apache ORC C++ writer (and so pyarrow) stores the negative fraction of a pre-1970 timestamp as is: 1969-07-20 20:17:40.5 is written as -14182939 seconds and -500000000 nanoseconds.
decodecast the nanoseconds tou64, so undoing the trailing-zero encoding overflowed: debug builds panic, and release builds fail the whole file.Separately,
decode_timestamprefused any value with digits below the requested unit, so a single nanosecond-precision value failed an entire read withwith_timestamp_precision(Microsecond).Change
i128so no input can overflow it.i64still fails withDecodeTimestamp.Adds unit tests for the negative-nanosecond case, truncation, and out-of-range values.
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warnings(default,--no-default-features,--all-features) pass.cargo test --all-features --no-fail-fastpasses except the 14tests/binCLI snapshot tests, which fail identically onmainon Windows (path/line-ending differences in the expected output).