[GH-3352] Read NULL GeoPackage date and datetime values as null - #3353
Merged
Conversation
ValuesMapper handed the raw string from the result set straight to DataTypesTransformations, whose parsers throw NullPointerException on null input. A single SQL NULL in a DATE or DATETIME column therefore aborted the whole scan. Map NULL through as null instead of parsing it, matching what the other column branches already do. The new fixture test_null_datetime.gpkg is a four-row GDAL-written layer with NULLs in both a DATE and a DATETIME column.
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.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes GeoPackage reader throws NullPointerException on NULL DATE or DATETIME values #3352What changes were proposed in this PR?
ValuesMappernow maps a SQL NULL in aDATEorDATETIMEcolumn tonullinstead of handing the null string toDataTypesTransformations, whose parsers throwNullPointerExceptionon it. Every other branch of the mapper already tolerates NULL (getString,getBytes,UTF8String.fromString); the two temporal branches were the only ones that parsed unconditionally.test_null_datetime.gpkg: a four-row GDAL-written layer covering all-set, both-null, date-only and datetime-only rows, and a test in the Spark 3.5, 4.0 and 4.1GeoPackageReaderTestsuites.How was this patch tested?
should read NULL date and datetime values as nullfails onmasterwith the stack trace from the issue (NullPointerException: textatDataTypesTransformations.getDays, called fromValuesMapper.scala:56) and passes with the fix.GeoPackageReaderTeston Spark 3.5: 18 of 19 pass locally; the remaining one is the MinIO test, which needs Docker and is unrelated.ogr2ogr -f GPKG -lco SPATIAL_INDEX=NOfrom a CSV plus a.csvtdeclaringDateandDateTimecolumns, so the column types and value formats are exactly what GDAL writes for real data.Did this PR include necessary documentation updates?