feat(bigquery-jdbc): implement picosecond temporal math and formatting engine - #14286
feat(bigquery-jdbc): implement picosecond temporal math and formatting engine#14286keshavdandeva wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces high-precision temporal formatting and parsing capabilities to BigQueryTemporalUtility to handle sub-nanosecond (picosecond) precision and prevent parser failures. Key additions include methods for parsing epoch decimals to Instant, formatting timestamp strings with configurable precision, and truncating sub-second fractions to nanoseconds. Unit tests have been expanded to cover these new features. The review feedback highlights a correctness bug in parseEpochDecimalToInstant when handling negative epoch decimals with sub-nanosecond precision, which causes incorrect rounding, and suggests adding a corresponding test case to prevent regressions.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enhances BigQueryTemporalUtility to support high-precision temporal formatting and parsing, specifically handling picosecond-level precision and preventing sub-second rollover. Feedback on the changes includes suggestions to trim trailing spaces before replacing spaces with 'T' to prevent parsing failures, and to robustly determine the correct timezone offset index when both '+' and '-' signs are present in the input string.
…ritize first sign
b/544839231
This PR implements the core temporal normalization and mathematical formatting engine in
BigQueryTemporalUtilityto support high-precisionTIMESTAMP(12)(picosecond) retrieval across both 6-digit microsecond and 12-digit picosecond scales.Key Changes
formatTimestampString: Formats epoch decimal strings into standard UTC JDBC timestamp format (yyyy-MM-dd HH:mm:ss.ffffff[ffffff]) with deterministicFLOOR/DOWNtruncation to prevent sub-second rollover on pre- and post-1970 epochs as well as scientific notation (1.69E9).formatTimestampStringFromIso: Linear 3-phase normalizer that preserves sub-nanosecond fractional digits (>9 digits) before passing base date-time components to JDK JSR-310 for UTC offset shifting.formatTimestampStringFromMicroseconds: Direct epoch microsecond formatter with zero-allocation in-place digit padding.parseEpochDecimalToInstant: Safely converts high-precision decimal epoch strings toInstantby truncating sub-nanoseconds to avoid arithmetic overflow.boxTimestamp,boxDateTime, andboxTimeto protect legacy JDBC/JDK parsers fromDateTimeParseExceptionon 12-digit literals.DateTimeFormatter.formatTo().appendPaddedto fill pre-allocatedStringBuilderbuffers in-place without intermediate heap string allocations.BigQueryTemporalUtilityTestcovering 12-digit precision formatting, 6-digit truncation, rollover prevention, pre-1970 negative epochs, scientific notation, and timezone boundary shifts.