Skip to content

[GH-3409] Read NULL GeoPackage integer, real and boolean values as null - #3410

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix-geopackage-null-values
Sep 28, 2026
Merged

jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:fix-geopackage-null-values

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 read INTEGER, SMALLINT, MEDIUMINT, FLOAT, DOUBLE, REAL and BOOLEAN columns with the JDBC primitive getters, which return 0, 0.0 or false for a SQL NULL, and never checked wasNull(). NULL cells therefore came back as real zeros and false, so IS NULL filters matched nothing and aggregates were skewed.

  • Check wasNull() after each primitive getter and return null when it is set (a small nullIfWasNull helper).
  • Add a GDAL-written fixture, test_null_values.gpkg, with an all-NULL row next to a row of zeros and false, to show that real zeros and false are still read as values. It follows the layout of the existing test_null_datetime.gpkg from [GH-3352] Read NULL GeoPackage date and datetime values as null #3353.

How was this patch tested?

  • New test should read NULL integer, real and boolean values as null in GeoPackageReaderTest. On master it fails with row 2 read as [2,0,0,0,0.0,0.0,false]; with the fix it reads [2,null,null,null,null,null,null].
  • GeoPackageReaderTest and GeometryReaderTest on the default profile: all pass except should be able to read files from S3, which needs Docker and could not start locally; it is unrelated to this change.

Did this PR include necessary documentation updates?

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

… as null

ValuesMapper read INTEGER, SMALLINT, MEDIUMINT, FLOAT, DOUBLE, REAL and
BOOLEAN columns with the JDBC primitive getters, which return 0, 0.0 or
false for a SQL NULL, and never checked wasNull(). NULL cells therefore
came back as real zeros and false, so IS NULL filters matched nothing and
aggregates were skewed.

Check wasNull() after each primitive getter and return null when it is
set. Add a small GDAL-written fixture with a row of all-NULL numeric and
boolean columns next to a row of zeros and false, to show that real zeros
and false are still read as values.
@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Sep 28, 2026
@jiayuasu
jiayuasu merged commit b93a916 into apache:master Sep 28, 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 reads NULL integer, real and boolean values as 0, 0.0 and false

1 participant