Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6423550
feat(sedona-raster): AsyncByteLoader trait + OutDbLoaderRegistry
james-willis May 27, 2026
a75126e
feat(sedona-expr): needs_bytes annotation on SedonaScalarUDF
james-willis May 27, 2026
ae65d5f
feat(sedona): RS_EnsureLoaded async UDF + register_outdb_loader API
james-willis May 27, 2026
b4c7338
feat(sedona): analyzer rule wraps needs_bytes UDFs with RS_EnsureLoaded
james-willis May 27, 2026
3f0b27c
feat(sedona-raster-gdal): GdalLoader implementing AsyncByteLoader
james-willis May 27, 2026
d7fce30
feat(sedona-raster-zarr): ZarrLoader implementing AsyncByteLoader
james-willis May 27, 2026
57e910d
chore: review revisions
james-willis May 28, 2026
d616992
feat(sedona-raster-gdal): block-aligned cancellable loop + byte cap
james-willis May 28, 2026
05fb09f
refactor(raster): host OutDb loader registry on ConfigOptions
james-willis May 29, 2026
4ec95e9
fix(raster): preserve raster extension in RS_EnsureLoaded output + De…
james-willis Jun 1, 2026
da6b533
refactor(raster): move RS_EnsureLoaded wrapping to a logical optimize…
james-willis Jun 1, 2026
486864b
refactor(raster): move RsEnsureLoaded to sedona-raster-functions; gen…
james-willis Jun 1, 2026
b856b49
docs(raster): link issue #897 from the view round-trip gap sites
james-willis Jun 1, 2026
b2de837
refactor(raster): derive Debug for OutDbLoaderRegistry
james-willis Jun 1, 2026
05a247d
fix(sedona-query-planner): commit the ensure_loaded.rs that the modul…
james-willis Jun 1, 2026
9abb8d5
revert(c/sedona-extension): drop the SedonaCScalarKernel metadata FFI…
james-willis Jun 1, 2026
9bdf464
Merge remote-tracking branch 'origin/main' into jw/outdb-loader-v2
james-willis Jun 2, 2026
9a2d1f1
refactor(raster): use sedona_internal_err!/plan_err! instead of Err(.…
james-willis Jun 2, 2026
7fdebc4
refactor(raster): trim RS_EnsureLoaded boilerplate; set ideal async b…
james-willis Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion c/sedona-extension/src/scalar_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ impl ExportedScalarKernel {
/// when passed across a boundary.
pub fn with_function_name(self, function_name: impl AsRef<str>) -> Self {
Self {
inner: self.inner,
function_name: Some(CString::from_str(function_name.as_ref()).unwrap()),
..self
}
}

Expand Down
72 changes: 65 additions & 7 deletions rust/sedona-expr/src/scalar_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
use std::{any::Any, fmt::Debug, sync::Arc};
use std::{any::Any, collections::HashMap, fmt::Debug, sync::Arc};

use arrow_schema::{DataType, FieldRef};
use datafusion_common::config::ConfigOptions;
Expand Down Expand Up @@ -60,6 +60,15 @@ impl<T: SedonaScalarKernel + 'static> IntoScalarKernelRefs for Vec<Arc<T>> {
}
}

/// Well-known [`SedonaScalarUDF`] metadata key marking a UDF whose
/// kernels read raster pixel bytes from their inputs. Presence with
/// value `"true"` is what the `RS_EnsureLoaded` optimizer rule keys off
/// to decide whether to wrap raster arguments. A generic string-keyed
/// metadata map (rather than a dedicated bool) keeps the UDF metadata
/// surface — and the eventual cross-cdylib FFI for it — extensible
/// without a schema change per flag.
pub const NEEDS_PIXELS_METADATA_KEY: &str = "needs_pixels";

/// Top-level scalar user-defined function
///
/// This struct implements datafusion's ScalarUDF and implements kernel dispatch
Expand All @@ -71,6 +80,13 @@ pub struct SedonaScalarUDF {
signature: Signature,
kernels: Vec<ScalarKernelRef>,
aliases: Vec<String>,
/// Class-level, string-keyed metadata describing this UDF to the
/// planner. Currently carries the [`NEEDS_PIXELS_METADATA_KEY`] flag
/// (set via [`SedonaScalarUDF::with_metadata`]) that the
/// `RS_EnsureLoaded` optimizer rule reads; the map shape leaves room
/// for further planner-visible flags — and a future cross-cdylib FFI
/// carrying them — without a new field per flag.
metadata: HashMap<String, String>,
}

impl PartialEq for SedonaScalarUDF {
Expand Down Expand Up @@ -191,17 +207,41 @@ impl SedonaScalarUDF {
signature,
kernels,
aliases: vec![],
metadata: HashMap::new(),
}
}

/// Add aliases to an existing SedonaScalarUDF
pub fn with_aliases(self, aliases: Vec<String>) -> SedonaScalarUDF {
Self {
name: self.name,
signature: self.signature,
kernels: self.kernels,
aliases,
}
Self { aliases, ..self }
}

/// Set a class-level metadata entry on this UDF, returning the
/// modified UDF. Metadata is planner-visible (e.g. the
/// `RS_EnsureLoaded` optimizer rule reads [`NEEDS_PIXELS_METADATA_KEY`])
/// and crosses the `sedona-extension` FFI boundary so plugin-defined
/// UDFs can declare it too.
pub fn with_metadata(
mut self,
key: impl Into<String>,
value: impl Into<String>,
) -> SedonaScalarUDF {
self.metadata.insert(key.into(), value.into());
self
}

/// Class-level metadata map describing this UDF to the planner.
pub fn metadata(&self) -> &HashMap<String, String> {
&self.metadata
}

/// Returns whether this UDF reads raster pixel bytes from its inputs
/// (i.e. carries [`NEEDS_PIXELS_METADATA_KEY`] = `"true"`).
pub fn needs_bytes(&self) -> bool {
self.metadata
.get(NEEDS_PIXELS_METADATA_KEY)
.map(String::as_str)
== Some("true")
}

/// Create a SedonaScalarUDF from a single kernel
Expand Down Expand Up @@ -334,6 +374,24 @@ mod tests {

use super::*;

#[test]
fn needs_bytes_defaults_false_and_flips_via_builder() {
let udf = SedonaScalarUDF::new("u", vec![], Volatility::Immutable);
assert!(!udf.needs_bytes());

let annotated = udf.with_metadata(NEEDS_PIXELS_METADATA_KEY, "true");
assert!(annotated.needs_bytes());
}

#[test]
fn needs_bytes_survives_with_aliases() {
let udf = SedonaScalarUDF::new("u", vec![], Volatility::Immutable)
.with_metadata(NEEDS_PIXELS_METADATA_KEY, "true")
.with_aliases(vec!["u_alias".to_string()]);
assert!(udf.needs_bytes());
assert_eq!(udf.aliases(), &["u_alias".to_string()]);
}

#[test]
fn udf_empty() -> Result<()> {
// UDF with no implementations
Expand Down
Loading
Loading