Skip to content

feat(rust/sedona-raster-functions): add RS_BandPixelType, RS_BandNoDataValue UDFs#612

Merged
Kontinuation merged 7 commits intoapache:mainfrom
Kontinuation:pr11-rs-band-accessors
Mar 4, 2026
Merged

feat(rust/sedona-raster-functions): add RS_BandPixelType, RS_BandNoDataValue UDFs#612
Kontinuation merged 7 commits intoapache:mainfrom
Kontinuation:pr11-rs-band-accessors

Conversation

@Kontinuation
Copy link
Copy Markdown
Member

@Kontinuation Kontinuation commented Feb 13, 2026

Summary

  • Add RS_BandPixelType and RS_BandNoDataValue raster UDFs to sedona-raster-functions
  • Each function supports per-band queries with an optional band index parameter (defaults to band 1)
  • Includes unit tests and benchmark entries in native-raster-functions.rs

@Kontinuation Kontinuation force-pushed the pr11-rs-band-accessors branch 4 times, most recently from ef916cd to abb1540 Compare February 19, 2026 17:31
@Kontinuation Kontinuation changed the title feat(raster): add RS_BandPixelType, RS_BandNoDataValue, RS_BandIsNoData UDFs feat(raster): add RS_BandPixelType, RS_BandNoDataValue UDFs Feb 19, 2026
@Kontinuation Kontinuation changed the title feat(raster): add RS_BandPixelType, RS_BandNoDataValue UDFs feat(rust/sedona-raster-functions): add RS_BandPixelType, RS_BandNoDataValue UDFs Feb 19, 2026
@Kontinuation Kontinuation marked this pull request as ready for review February 19, 2026 17:38
@Kontinuation Kontinuation force-pushed the pr11-rs-band-accessors branch from abb1540 to 61fcb0c Compare February 20, 2026 17:02
Copy link
Copy Markdown
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you!

This may fail main CI if it doesn't have docs files (also probably a good idea to add them).

) -> Result<ColumnarValue> {
let executor = RasterExecutor::new(arg_types, args);
let band_index_array = args[1].clone().into_array(executor.num_iterations())?;
let band_index_array = band_index_array.as_primitive::<Int32Type>();
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.

Probably better to use DataFusion's downcasting here (as_int32_array(), checks the downcast and returns an internal error in debug mode).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have found that we need to cast the band index here before calling as_int32_array. I have switched to calling as_int32_array and added the cast.

…DataValue, RS_BandIsNoData

Replace local band_data_type_name(), data_type_byte_size(), bytes_to_f64(),
and validate_band_index() helpers with shared BandDataType.pixel_type_name(),
BandDataType.byte_size(), BandMetadataRef.nodata_value_as_f64(), and
raster_utils::validate_band_index() from pr15-raster-utilities.
- Replace as_primitive::<Int32Type>() with datafusion_common::cast::as_int32_array()
  for checked downcasting of band index arrays
- Add .qmd documentation files for RS_BandPixelType and RS_BandNoDataValue
@Kontinuation Kontinuation force-pushed the pr11-rs-band-accessors branch from dbcec30 to f74e6aa Compare March 3, 2026 13:27
SQL integer literals are inferred as Int64 by DataFusion, but
as_int32_array/as_primitive<Int32Type> require exactly Int32. Add
cast_to(&DataType::Int32) before into_array() to handle any integer
width, matching the pattern used by other UDFs (rs_worldcoordinate,
rs_setsrid, etc.).
@Kontinuation Kontinuation merged commit 563114e into apache:main Mar 4, 2026
17 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.

2 participants