Fix Date fields in complex types returning epoch day integers#1248
Merged
vikrantpuppala merged 3 commits intodatabricks:mainfrom Mar 9, 2026
Merged
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.
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))); |
Collaborator
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
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 <noreply@anthropic.com> Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
… 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 <noreply@anthropic.com> Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
…E parsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
def7071 to
529df0f
Compare
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