Skip to content

[GH-3352] Read NULL GeoPackage date and datetime values as null - #3353

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:gpkg-null-datetime
Sep 12, 2026
Merged

[GH-3352] Read NULL GeoPackage date and datetime values as null#3353
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:gpkg-null-datetime

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

  • ValuesMapper now maps a SQL NULL in a DATE or DATETIME column to null instead of handing the null string to DataTypesTransformations, whose parsers throw NullPointerException on 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.
  • New fixture 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.1 GeoPackageReaderTest suites.

How was this patch tested?

  • The new test should read NULL date and datetime values as null fails on master with the stack trace from the issue (NullPointerException: text at DataTypesTransformations.getDays, called from ValuesMapper.scala:56) and passes with the fix.
  • GeoPackageReaderTest on Spark 3.5: 18 of 19 pass locally; the remaining one is the MinIO test, which needs Docker and is unrelated.
  • The fixture was built with ogr2ogr -f GPKG -lco SPATIAL_INDEX=NO from a CSV plus a .csvt declaring Date and DateTime columns, so the column types and value formats are exactly what GDAL writes for real data.

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API so no need to change the documentation.

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.
@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Sep 12, 2026
@jiayuasu
jiayuasu merged commit a870e2b into apache:master Sep 12, 2026
36 of 46 checks passed
@jiayuasu
jiayuasu deleted the gpkg-null-datetime branch September 12, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoPackage reader throws NullPointerException on NULL DATE or DATETIME values

1 participant