Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 2 additions & 10 deletions c/sedona-extension/src/scalar_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,8 @@ mod test {

let array_value = create_array(&[Some("POINT (0 1)"), None], &WKB_GEOMETRY);

let udf_native = SedonaScalarUDF::new(
"simple_udf",
vec![kernel.clone()],
Volatility::Immutable,
None,
);
let udf_native =
SedonaScalarUDF::new("simple_udf", vec![kernel.clone()], Volatility::Immutable);

let tester = ScalarUdfTester::new(udf_native.into(), vec![WKB_GEOMETRY]);
tester.assert_return_type(WKB_GEOMETRY);
Expand All @@ -721,7 +717,6 @@ mod test {
"simple_udf_from_ffi",
vec![Arc::new(imported_kernel)],
Volatility::Immutable,
None,
);

let ffi_tester = ScalarUdfTester::new(udf_from_ffi.clone().into(), vec![WKB_GEOMETRY]);
Expand Down Expand Up @@ -776,7 +771,6 @@ mod test {
"simple_udf_from_ffi",
vec![Arc::new(imported_kernel)],
Volatility::Immutable,
None,
);

let ffi_tester = ScalarUdfTester::new(
Expand Down Expand Up @@ -831,7 +825,6 @@ mod test {
"simple_udf_from_ffi",
vec![Arc::new(imported_kernel)],
Volatility::Immutable,
None,
);

let ffi_tester = ScalarUdfTester::new(udf_from_ffi.clone().into(), vec![WKB_GEOMETRY]);
Expand All @@ -855,7 +848,6 @@ mod test {
"simple_udf_from_ffi",
vec![Arc::new(imported_kernel)],
Volatility::Immutable,
None,
);

let ffi_tester = ScalarUdfTester::new(udf_from_ffi.clone().into(), vec![WKB_GEOMETRY]);
Expand Down
1 change: 0 additions & 1 deletion c/sedona-geos/src/st_polygonize_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ mod tests {
"st_polygonize_agg",
st_polygonize_agg_impl(),
datafusion_expr::Volatility::Immutable,
None,
)
}

Expand Down
44 changes: 44 additions & 0 deletions docs/reference/sql/rs_georeference.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

title: RS_GeoReference
description: >
Returns the georeference metadata of raster as a string in GDAL or ESRI format
as commonly seen in a world file. Default is GDAL if not specified. Both formats
output six lines: scalex, skewy, skewx, scaley, upperleftx, upperlefty. In GDAL
format the upper-left coordinates refer to the corner of the upper-left pixel,
while in ESRI format they are shifted to the center of the upper-left pixel.
kernels:
- returns: utf8
args: [raster]
- returns: utf8
args:
- raster
- name: format
type: utf8
description: >
Output format, either 'GDAL' (default) or 'ESRI'. GDAL reports the
upper-left corner of the upper-left pixel; ESRI shifts the coordinates
to the center of the upper-left pixel.
---

## Examples

```sql
SELECT RS_GeoReference(RS_Example());
```
30 changes: 30 additions & 0 deletions docs/reference/sql/rs_numbands.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

title: RS_NumBands
description: Returns the number of bands in the raster.
kernels:
- returns: uint32
args: [raster]
---

## Examples

```sql
SELECT RS_NumBands(RS_Example());
```
3 changes: 1 addition & 2 deletions python/sedonadb/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ pub fn sedona_scalar_udf<'py>(
};

let scalar_kernel = sedona_scalar_kernel(py, py_input_types, py_return_type, py_invoke_batch)?;
let sedona_scalar_udf =
SedonaScalarUDF::new(name, vec![Arc::new(scalar_kernel)], volatility, None);
let sedona_scalar_udf = SedonaScalarUDF::new(name, vec![Arc::new(scalar_kernel)], volatility);

Ok(PySedonaScalarUdf {
inner: sedona_scalar_udf,
Expand Down
16 changes: 3 additions & 13 deletions rust/sedona-expr/src/aggregate_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct SedonaAggregateUDF {
name: String,
signature: Signature,
kernels: Vec<SedonaAccumulatorRef>,
documentation: Option<Documentation>,
}

impl PartialEq for SedonaAggregateUDF {
Expand All @@ -93,14 +92,12 @@ impl SedonaAggregateUDF {
name: &str,
kernels: impl IntoSedonaAccumulatorRefs,
volatility: Volatility,
documentation: Option<Documentation>,
) -> Self {
let signature = Signature::user_defined(volatility);
Self {
name: name.to_string(),
signature,
kernels: kernels.into_sedona_accumulator_refs(),
documentation,
}
}

Expand All @@ -111,14 +108,9 @@ impl SedonaAggregateUDF {
/// expected that the actual functionality will be registered from one or more
/// independent crates (e.g., ST_Union_Agg(), which may be implemented in
/// sedona-geo or sedona-geography).
pub fn new_stub(
name: &str,
arg_matcher: ArgMatcher,
volatility: Volatility,
documentation: Option<Documentation>,
) -> Self {
pub fn new_stub(name: &str, arg_matcher: ArgMatcher, volatility: Volatility) -> Self {
let stub_kernel = StubAccumulator::new(name.to_string(), arg_matcher);
Self::new(name, stub_kernel, volatility, documentation)
Self::new(name, stub_kernel, volatility)
}

/// Add a new kernel to an Aggregate UDF
Expand Down Expand Up @@ -226,7 +218,7 @@ impl AggregateUDFImpl for SedonaAggregateUDF {
}

fn documentation(&self) -> Option<&Documentation> {
self.documentation.as_ref()
None
}
}

Expand Down Expand Up @@ -317,7 +309,6 @@ mod test {
"empty",
Vec::<SedonaAccumulatorRef>::new(),
Volatility::Immutable,
None,
);
assert_eq!(udf.name(), "empty");
let err = udf.return_field(&[]).unwrap_err();
Expand All @@ -340,7 +331,6 @@ mod test {
"stubby",
ArgMatcher::new(vec![], SedonaType::Arrow(DataType::Boolean)),
Volatility::Immutable,
None,
);

// We registered the stub with zero arguments, so when we call it
Expand Down
11 changes: 2 additions & 9 deletions rust/sedona-expr/src/function_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,7 @@ mod tests {
Arc::new(|_, _| Ok(ColumnarValue::Scalar(ScalarValue::Boolean(None)))),
);

let udf = SedonaScalarUDF::new(
"simple_udf",
vec![kernel.clone()],
Volatility::Immutable,
None,
);
let udf = SedonaScalarUDF::new("simple_udf", vec![kernel.clone()], Volatility::Immutable);

functions.insert_scalar_udf(udf);
assert_eq!(functions.scalar_udfs().collect::<Vec<_>>().len(), 1);
Expand All @@ -201,7 +196,7 @@ mod tests {
Arc::new(|_, _| Ok(ColumnarValue::Scalar(ScalarValue::Utf8(None)))),
);

let udf2 = SedonaScalarUDF::new("simple_udf2", vec![kernel2], Volatility::Immutable, None);
let udf2 = SedonaScalarUDF::new("simple_udf2", vec![kernel2], Volatility::Immutable);
let mut functions2 = FunctionSet::new();
functions2.insert_scalar_udf(udf2);
functions.merge(functions2);
Expand Down Expand Up @@ -252,7 +247,6 @@ mod tests {
"simple_udaf",
Vec::<SedonaAccumulatorRef>::new(),
Volatility::Immutable,
None,
);
let kernel = TestAccumulator {};

Expand All @@ -278,7 +272,6 @@ mod tests {
"simple_udaf2",
vec![Arc::new(kernel.clone())],
Volatility::Immutable,
None,
);
let mut functions2 = FunctionSet::new();
functions2.insert_aggregate_udf(udaf2);
Expand Down
22 changes: 4 additions & 18 deletions rust/sedona-expr/src/scalar_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct SedonaScalarUDF {
name: String,
signature: Signature,
kernels: Vec<ScalarKernelRef>,
documentation: Option<Documentation>,
aliases: Vec<String>,
}

Expand Down Expand Up @@ -185,14 +184,12 @@ impl SedonaScalarUDF {
name: &str,
kernels: Vec<ScalarKernelRef>,
volatility: Volatility,
documentation: Option<Documentation>,
) -> SedonaScalarUDF {
let signature = Signature::user_defined(volatility);
Self {
name: name.to_string(),
signature,
kernels,
documentation,
aliases: vec![],
}
}
Expand All @@ -203,7 +200,6 @@ impl SedonaScalarUDF {
name: self.name,
signature: self.signature,
kernels: self.kernels,
documentation: self.documentation,
aliases,
}
}
Expand All @@ -214,12 +210,7 @@ impl SedonaScalarUDF {
/// arguments. This is useful to create stub functions when it is expected that the
/// actual functionality will be registered from one or more independent crates
/// (e.g., ST_Intersects(), which may be implemented in sedona-geo or sedona-geography).
pub fn new_stub(
name: &str,
arg_matcher: ArgMatcher,
volatility: Volatility,
documentation: Option<Documentation>,
) -> Self {
pub fn new_stub(name: &str, arg_matcher: ArgMatcher, volatility: Volatility) -> Self {
let name_string = name.to_string();
let stub_kernel = SimpleSedonaScalarKernel::new_ref(
arg_matcher,
Expand All @@ -228,7 +219,7 @@ impl SedonaScalarUDF {
}),
);

Self::new(name, vec![stub_kernel], volatility, documentation)
Self::new(name, vec![stub_kernel], volatility)
}

/// Create a SedonaScalarUDF from a single kernel
Expand All @@ -240,7 +231,6 @@ impl SedonaScalarUDF {
name,
kernels.into_scalar_kernel_refs(),
Volatility::Immutable,
None,
)
}

Expand Down Expand Up @@ -284,7 +274,7 @@ impl ScalarUDFImpl for SedonaScalarUDF {
}

fn documentation(&self) -> Option<&Documentation> {
self.documentation.as_ref()
None
}

fn return_type(&self, _args: &[DataType]) -> Result<DataType> {
Expand Down Expand Up @@ -355,7 +345,7 @@ mod tests {
#[test]
fn udf_empty() -> Result<()> {
// UDF with no implementations
let udf = SedonaScalarUDF::new("empty", vec![], Volatility::Immutable, None);
let udf = SedonaScalarUDF::new("empty", vec![], Volatility::Immutable);
assert_eq!(udf.name(), "empty");
assert_eq!(udf.coerce_types(&[])?, vec![]);

Expand Down Expand Up @@ -397,7 +387,6 @@ mod tests {
"simple_udf",
vec![kernel_geo, kernel_arrow],
Volatility::Immutable,
None,
);

// Calling with a geo type should return a Null type
Expand Down Expand Up @@ -443,7 +432,6 @@ mod tests {
"stubby",
ArgMatcher::new(vec![], SedonaType::Arrow(DataType::Boolean)),
Volatility::Immutable,
None,
);
let tester = ScalarUdfTester::new(stub.into(), vec![]);
tester.assert_return_type(DataType::Boolean);
Expand All @@ -465,7 +453,6 @@ mod tests {
SedonaType::Arrow(DataType::Boolean),
),
Volatility::Immutable,
None,
);

// None CRS to None CRS is OK
Expand Down Expand Up @@ -498,7 +485,6 @@ mod tests {
WKB_GEOMETRY,
),
Volatility::Immutable,
None,
);

let tester = ScalarUdfTester::new(
Expand Down
1 change: 0 additions & 1 deletion rust/sedona-functions/src/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub fn barrier_udf() -> SedonaScalarUDF {
"barrier",
vec![Arc::new(Barrier)],
Volatility::Volatile, // Mark as volatile to prevent optimization
None,
)
}

Expand Down
1 change: 0 additions & 1 deletion rust/sedona-functions/src/distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub fn distance_stub_udf(name: &str) -> SedonaScalarUDF {
SedonaType::Arrow(DataType::Float64),
),
Volatility::Immutable,
None,
)
}

Expand Down
1 change: 0 additions & 1 deletion rust/sedona-functions/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub fn overlay_stub_udf(name: &str) -> SedonaScalarUDF {
WKB_GEOMETRY,
),
Volatility::Immutable,
None,
)
}

Expand Down
2 changes: 0 additions & 2 deletions rust/sedona-functions/src/predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub fn st_knn_udf() -> SedonaScalarUDF {
SedonaType::Arrow(DataType::Boolean),
),
Volatility::Immutable,
None,
)
}

Expand All @@ -92,7 +91,6 @@ pub fn predicate_stub_udf(name: &str) -> SedonaScalarUDF {
SedonaType::Arrow(DataType::Boolean),
),
Volatility::Immutable,
None,
)
}

Expand Down
Loading