paleolimbot commented on code in PR #750:
URL: https://github.com/apache/sedona-db/pull/750#discussion_r3227482250
##########
rust/sedona-raster-functions/src/rs_convexhull.rs:
##########
@@ -107,8 +107,18 @@ impl SedonaScalarKernel for RsConvexHull {
/// of the raster in world coordinates. Due to skew/rotation in the affine
/// transformation, each corner must be computed individually.
fn write_convexhull_wkb(raster: &dyn RasterRef, out: &mut impl std::io::Write)
-> Result<()> {
- let width = raster.metadata().width() as i64;
- let height = raster.metadata().height() as i64;
+ let Some(width) = raster.width() else {
+ return Err(DataFusionError::Execution(
+ "Raster has no spatial dimensions; cannot determine width".into(),
+ ));
+ };
+ let Some(height) = raster.height() else {
+ return Err(DataFusionError::Execution(
+ "Raster has no spatial dimensions; cannot determine height".into(),
+ ));
+ };
+ let width = width as i64;
+ let height = height as i64;
Review Comment:
Should this be checked in the executor before it reaches the function? Or
should `width()` return a `Result<>` that propagates this error so it doesn't
have to be copy/pasted?
##########
rust/sedona-raster-functions/src/rs_band_accessors.rs:
##########
@@ -224,16 +225,19 @@ fn get_nodata_value(
Ok(())
}
Some(raster) => {
- let num_bands = raster.bands().len();
+ let num_bands = raster.num_bands();
if band_index < 1 || band_index > num_bands as i32 {
builder.append_null();
return Ok(());
}
- let band = raster.bands().band(band_index as usize)?;
- let band_meta = band.metadata();
- match band_meta.nodata_value_as_f64()? {
- None => builder.append_null(),
- Some(val) => builder.append_value(val),
+ let idx = (band_index - 1) as usize;
+ match (raster.band_nodata(idx), raster.band_data_type(idx)) {
+ (Some(bytes), Some(dt)) => {
+ let val = nodata_bytes_to_f64(bytes, &dt)
+ .map_err(datafusion_common::DataFusionError::from)?;
Review Comment:
Can you make sure that `nodata_bytes_to_f64()` errors for int64 and uint64
types where this conversion is lossy? (At least one version I reviewed does but
we have some duplication and it's a good time to make sure)
--
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]