Repository navigation
Fix Date fields in complex types returning epoch day integers - #1248
Merged
vikrantpuppala merged 3 commits intoMar 9, 2026
Merged
vikrantpuppala merged 3 commits into
vikrantpuppala merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect DATE handling inside nested/complex types where Arrow can surface DATEs as epoch-day integers, ensuring parsed results become proper java.sql.Date objects instead of numeric day counts.
Changes:
- Added DATE parsing fallback to interpret non-ISO DATE inputs as epoch-day integers via
LocalDate.ofEpochDay(...). - Added regression tests covering DATE epoch-day integers in
ARRAY<STRUCT<...>>,ARRAY<DATE>, andMAP<*,DATE>, plus a non-regression test for ISO-8601 date strings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/com/databricks/jdbc/api/impl/ComplexDataTypeParser.java | Adds epoch-day integer fallback when DATE parsing via Date.valueOf(String) fails. |
| src/test/java/com/databricks/jdbc/api/impl/ComplexDataTypeParserTest.java | Adds tests validating epoch-day DATE handling across nested ARRAY/STRUCT/MAP scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3 of 4 tasks
sreekanth-db
reviewed
Mar 5, 2026
Collaborator
Author
|
@sreekanth-db see #1250 |
sreekanth-db
approved these changes
Mar 5, 2026
madhav-db
approved these changes
Mar 5, 2026
| // Arrow serializes DATE fields in nested types as epoch day integers. | ||
| // Fall back to parsing as epoch day count (days since 1970-01-01). | ||
| try { | ||
| return Date.valueOf(LocalDate.ofEpochDay(Long.parseLong(text))); |
Contributor
There was a problem hiding this comment.
nit: Should catch a DateTimeException here too, in case Long.parseLong returns an out-of-range value for LocalDate
samikshya-db
approved these changes
Mar 6, 2026
gopalldb
reviewed
Mar 6, 2026
| try { | ||
| return Date.valueOf(LocalDate.ofEpochDay(Long.parseLong(text))); | ||
| } catch (NumberFormatException nfe) { | ||
| throw e; |
gopalldb
approved these changes
Mar 6, 2026
vikrantpuppala
force-pushed
the
fix/1247-date-epoch-day-in-complex-types
branch
from
March 9, 2026 13:47
f43f071 to
def7071
Compare
… of date strings When Arrow serializes DATE fields inside nested types (ARRAY, STRUCT, MAP), getObject() returns epoch day integers rather than ISO-8601 date strings. ComplexDataTypeParser.convertPrimitive() now falls back to parsing epoch day integers via LocalDate.ofEpochDay() when Date.valueOf() fails. Closes databricks#1247 Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Vikrant Puppala <[email protected]>
… add changelog - Wrap epoch-day fallback in try-catch so non-numeric invalid date strings (e.g., "2026/02/03") rethrow the original IllegalArgumentException instead of a NumberFormatException. - Add test for invalid date string error behavior. - Add NEXT_CHANGELOG.md entry for the user-facing bug fix. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Vikrant Puppala <[email protected]>
…E parsing Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Vikrant Puppala <[email protected]>
vikrantpuppala
force-pushed
the
fix/1247-date-epoch-day-in-complex-types
branch
from
March 9, 2026 13:47
def7071 to
529df0f
Compare
vikrantpuppala
enabled auto-merge (squash)
March 9, 2026 13:48
vikrantpuppala
added a commit
that referenced
this pull request
Mar 20, 2026
…ats (#1250) ## Summary - **TIMESTAMP / TIMESTAMP_NTZ** fields inside complex types (ARRAY, MAP, STRUCT) are serialized as epoch microseconds by Arrow. Added fallback to convert epoch micros to `java.sql.Timestamp`. Also handles TIMESTAMP_NTZ serialized as `[year,month,day,hour,min,sec]` component arrays. - **BINARY** fields inside complex types are serialized as base64-encoded strings by Arrow. Added base64 decoding in `convertPrimitive()`. - Added `TIMESTAMP_NTZ` case to `DatabricksStruct.convertSimpleValue()` and `DatabricksArray.convertValue()` switch statements that were missing it. - Added server-format comments documenting how Arrow serializes each type within nested structures. Related: #1247, #1248 ## Test plan - [x] 7 new unit tests covering TIMESTAMP, TIMESTAMP_NTZ, and BINARY across struct, array, and map containers - [x] All 20 tests in `ComplexDataTypeParserTest` pass - [x] Server output formats verified via E2E tests against real Databricks warehouse - [ ] CI passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Vikrant Puppala <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
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.
Summary
ARRAY<STRUCT>,ARRAY<DATE>,MAP<*,DATE>, and other complex types were serialized as epoch day integers instead of properjava.sql.Dateobjects.getObject()on nested types returns epoch day integers for DATE fields.ComplexDataTypeParser.convertPrimitive()now falls back to parsing epoch day integers viaLocalDate.ofEpochDay()whenDate.valueOf()fails on non-ISO-8601 input.IllegalArgumentException.Test plan
testDateAsEpochDayInStruct— verifies DATE epoch day integers inARRAY<STRUCT<event_date:DATE>>testDateAsEpochDayInArray— verifies DATE epoch day integers inARRAY<DATE>testDateAsEpochDayInMap— verifies DATE epoch day integers inMAP<STRING,DATE>testDateAsStringInStruct— verifies ISO-8601 date strings still work (no regression)testInvalidDateStringInStructThrowsOriginalException— verifies error behavior for invalid stringsComplexDataTypeParserTesttests pass🤖 Generated with Claude Code