Skip to content

[GH-3502] Read a NULL GeoPackage geometry as null - #3503

Merged
jiayuasu merged 1 commit into
apache:masterfrom
Mayukh-D:GH-3502-geopackage-null-geometry
Oct 25, 2026
Merged

jiayuasu merged 1 commit into
apache:masterfrom
Mayukh-D:GH-3502-geopackage-null-geometry

Conversation

@Mayukh-D

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

GeometryReader.extractWKB now returns null when the GeoPackage geometry blob is null, which is what the driver returns for a NULL in a geometry column. Previously it called ByteBuffer.wrap on the null array and the NullPointerException aborted the whole scan. Every geometry type in ValuesMapper goes through extractWKB, so this covers all of them.

This follows the same pattern as #3353 for NULL date and datetime values and #3410 for numeric and boolean columns.

How was this patch tested?

  • Added test_null_geometry.gpkg, a copy of test_null_values.gpkg (from [GH-3409] Read NULL GeoPackage integer, real and boolean values as null #3410) with row 2's geometry set to NULL and the names relabelled.
  • GeoPackageReaderTest: "should read a NULL geometry as null" reads that file and checks that only row 2 has a null geometry and that its name is still read.
  • GeometryReaderTest: "extractWKB returns null for a NULL geometry".
  • Both tests fail on master with the NullPointerException from the issue and pass with this change. All 27 GeoPackage tests pass on Spark 3.5 / Scala 2.12, 4.0 / 2.13 and 4.1 / 2.13 (including the S3 test, which needs Docker).

Did this PR include necessary documentation updates?

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

Assisted by Claude Code
Generated-by: Claude Code (Claude Opus 5.5)

A NULL in a GeoPackage geometry column comes back from the driver as a
null byte array. GeometryReader.extractWKB wrapped it in a ByteBuffer
straight away, and the NullPointerException aborted the whole scan.
Return null for a null blob instead. Every geometry type in ValuesMapper
goes through extractWKB, so this covers all of them.

Generated-by: Claude Code (Claude Opus 5.5)

@jiayuasu jiayuasu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jiayuasu
jiayuasu merged commit f702af5 into apache:master Oct 25, 2026
41 checks passed
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 a NULL geometry

2 participants