Skip to content

[GH-1951] Support zstd-compressed NetCDF4 in RS_FromNetCDF - #3379

Merged
jiayuasu merged 1 commit into
apache:masterfrom
minhpham1810:GH-1951-netcdf-zstd
Sep 17, 2026
Merged

jiayuasu merged 1 commit into
apache:masterfrom
minhpham1810:GH-1951-netcdf-zstd

Conversation

@minhpham1810

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?

RS_FromNetCDF failed on NetCDF4/HDF5 variables compressed with Zstandard (HDF5 filter 32015) with Unknown filter type=32015.

  • Upgrade netCDF-Java (cdm-core) from 5.4.2 to 5.10.0. In 5.4.2 the HDF5 filters are hardcoded. Since 5.5.0, netCDF-Java loads them through the ucar.nc2.filter.FilterProvider service. 5.10.0 is still Java 8 bytecode. On the transitive side, the only changes are version bumps of jcommander, joda-time, jdom2 and httpmime.
  • netCDF-Java has no Zstandard filter, so this PR adds ZstdFilter and registers it in META-INF/services/ucar.nc2.filter.FilterProvider. It decodes with zstd-jni, added as a provided dependency because Spark 3.5, 4.0 and 4.1 already ship it.
  • Instead of a custom error message, this relies on netCDF-Java 5.10.0, which already reports other unsupported filters with their id (for example Unknown filter: no filter found with id 307). The docs now list the supported filters and the nccopy -F none workaround.

How was this patch tested?

  • New RasterConstructorsTest#testNetCdfZstdCompressed, using a small Zstandard-compressed fixture (test_zstd.nc4) generated with netCDF4-python. It checks the raster metadata and every pixel value.
    • It fails on 5.4.2 with the exact error from the issue.
    • It also fails on 5.10.0 when the service file is removed, with no filter found with id 32015.
  • Existing NetCDF tests pass on 5.10.0: RasterConstructorsTest, plus netcdfMetadataTest and rasteralgebraTest (Spark 3.5, Scala 2.13).

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

- Upgrade netCDF-Java (cdm-core) from 5.4.2 to 5.10.0, which loads HDF5
  filters through the ucar.nc2.filter.FilterProvider service.
- Add a Zstandard filter (HDF5 filter id 32015) backed by zstd-jni, which
  Spark already ships. zstd-jni is a provided dependency.
- Document the supported compression filters and the new netCDF-Java version.
@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Sep 17, 2026

@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 3760de2 into apache:master Sep 17, 2026
43 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.

RS_FromNetCDF fails on NetCDF4/HDF5 with filter type=32015 (e.g. ZSTD)

2 participants