jiayuasu opened a new issue, #3245:
URL: https://github.com/apache/sedona/issues/3245
## Expected behavior
`RS_AsCOG` should encode rasters of any size and band data type, or fail
with a clear message about unsupported inputs.
## Actual behavior
Encoding a **1024×1024 raster with a byte band** throws:
```
org.apache.spark.sql.sedona_sql.expressions.InferredExpressionException:
Exception occurred while evaluating expression RS_AsCOG ...
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.base/java.util.zip.Deflater.setInput(Deflater.java:242)
at
it.geosolutions.imageio.compression.zipdeflate.ZipDeflateCompressor.compress(ZipDeflateCompressor.java:58)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFDeflater.encode(TIFFDeflater.java:164)
at
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageWriter.writeTile(TIFFImageWriter.java:1912)
```
The failure is specific to that size/type combination. Probe matrix (each
cell is `RS_AsCOG(RS_MakeEmptyRaster(1, '<type>', <size>, <size>, 10.0, 52.0,
0.001, -0.001, 0, 0, 4326))`):
| size | 'B' (byte) | 'I' (int) | 'D' (double) |
|------|------------|-----------|--------------|
| 256 | OK | OK | OK |
| 512 | OK | OK | OK |
| 768 | OK | OK | OK |
| 1024 | **ArrayIndexOutOfBoundsException** | OK | OK |
`RS_AsGeoTiff` on the same 1024×1024 byte raster works fine; only the COG
path fails, which suggests the tiled/Deflate encode path in the geosolutions
TIFF writer receives a mis-sized buffer for single-byte samples at this
dimension.
## Steps to reproduce the problem
```sql
SELECT RS_AsCOG(RS_MakeEmptyRaster(1, 'B', 1024, 1024, 10.0, 52.0, 0.001,
-0.001, 0, 0, 4326));
-- ArrayIndexOutOfBoundsException at java.util.zip.Deflater.setInput
```
Any 1024×1024 single-band byte raster reproduces it; found while generating
sample GeoTIFF fleets with the raster writer.
## Settings
Sedona version = 1.9.1 (release artifacts from Maven Central:
sedona-spark-shaded-3.5_2.12:1.9.1, geotools-wrapper:1.9.1-33.5)
Apache Spark version = 3.5.3
Apache Flink version = N/A
API type = Python (SQL expression; the failure is in the JVM encode path)
Scala version = 2.12
JRE version = 11
Python version = 3.12
Environment = Standalone (local[*])
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]