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
7 changes: 4 additions & 3 deletions c/sedona-geoarrow-c/src/kernels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ mod tests {
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOGRAPHY, WKB_GEOMETRY, WKB_VIEW_GEOMETRY};

use sedona_testing::{create::create_scalar_storage, testers::ScalarUdfTester};
use sedona_testing::{
create::{create_array, create_scalar_storage},
testers::ScalarUdfTester,
};

use super::*;

#[rstest]
fn fromwkt(#[values(DataType::Utf8, DataType::Utf8View)] data_type: DataType) {
use sedona_testing::create::create_array;

let udf = SedonaScalarUDF::from_kernel("st_geomfromwkt", st_geomfromwkt_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![SedonaType::Arrow(data_type)]);
tester.assert_return_type(WKB_GEOMETRY);
Expand Down
17 changes: 1 addition & 16 deletions c/sedona-geos/src/binary_predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl<Op: BinaryPredicate> SedonaScalarKernel for GeosPredicate<Op> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -115,8 +116,6 @@ mod tests {

#[rstest]
fn contains_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_contains", st_contains_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -154,8 +153,6 @@ mod tests {

#[rstest]
fn covered_by_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_coveredby", st_covered_by_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -193,8 +190,6 @@ mod tests {

#[rstest]
fn covers_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_covers", st_covers_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -232,8 +227,6 @@ mod tests {

#[rstest]
fn disjoint_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_disjoint", st_disjoint_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -271,8 +264,6 @@ mod tests {

#[rstest]
fn equals_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_equals", st_equals_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -310,8 +301,6 @@ mod tests {

#[rstest]
fn intersects_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_intersects", st_intersects_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -349,8 +338,6 @@ mod tests {

#[rstest]
fn within_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_within", st_within_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -388,7 +375,6 @@ mod tests {

#[rstest]
fn crosses_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;
let udf = SedonaScalarUDF::from_kernel("st_crosses", st_crosses_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down Expand Up @@ -425,7 +411,6 @@ mod tests {

#[rstest]
fn overlaps_udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;
let udf = SedonaScalarUDF::from_kernel("st_overlaps", st_overlaps_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Boolean);
Expand Down
3 changes: 1 addition & 2 deletions c/sedona-geos/src/distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn invoke_scalar(geos_geom: &geos::Geometry, other_geos_geom: &geos::Geometry) -
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -88,8 +89,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_distance", st_distance_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type.clone(), sedona_type]);
tester.assert_return_type(DataType::Float64);
Expand Down
3 changes: 1 addition & 2 deletions c/sedona-geos/src/st_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn invoke_scalar(geos_geom: &geos::Geometry) -> Result<f64> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -84,8 +85,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_area", st_area_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type]);
tester.assert_return_type(DataType::Float64);
Expand Down
3 changes: 1 addition & 2 deletions c/sedona-geos/src/st_dwithin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn invoke_scalar(lhs: &geos::Geometry, rhs: &geos::Geometry, distance: f64) -> R
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -93,8 +94,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_dwithin", st_dwithin_impl());
let tester = ScalarUdfTester::new(
udf.into(),
Expand Down
3 changes: 1 addition & 2 deletions c/sedona-geos/src/st_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fn invoke_scalar(geos_geom: &geos::Geometry) -> GResult<f64> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -105,8 +106,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_length", st_length_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type]);
tester.assert_return_type(DataType::Float64);
Expand Down
3 changes: 1 addition & 2 deletions c/sedona-geos/src/st_perimeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fn invoke_scalar(geos_geom: &geos::Geometry) -> GResult<f64> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array, ArrayRef};
use datafusion_common::ScalarValue;
use rstest::rstest;
use sedona_expr::scalar_udf::SedonaScalarUDF;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -104,8 +105,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf = SedonaScalarUDF::from_kernel("st_perimeter", st_perimeter_impl());
let tester = ScalarUdfTester::new(udf.into(), vec![sedona_type]);
tester.assert_return_type(DataType::Float64);
Expand Down
4 changes: 1 addition & 3 deletions rust/sedona-functions/src/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ impl Barrier {
/// Compare two scalar values using the given operator
fn compare_values(left: &ScalarValue, op: &str, right: &ScalarValue) -> Result<bool> {
use ScalarValue::*;

match (left, right) {
(Int64(Some(l)), Int64(Some(r))) => match op {
"=" | "==" => Ok(l == r),
Expand Down Expand Up @@ -386,6 +385,7 @@ mod tests {
use super::*;
use arrow_array::RecordBatch;
use arrow_schema::{Field, Schema};
use datafusion::prelude::SessionContext;
use datafusion_expr::ScalarUDF;
use sedona_testing::testers::ScalarUdfTester;

Expand Down Expand Up @@ -652,8 +652,6 @@ mod tests {
expression: &str,
column_values: &[(&str, ScalarValue)],
) -> Result<bool> {
use datafusion::prelude::SessionContext;

// Create schema from column values
let mut fields = vec![];
let mut arrays = vec![];
Expand Down
3 changes: 1 addition & 2 deletions rust/sedona-functions/src/st_dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ fn invoke_scalar(item: &Wkb) -> Result<i8> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use datafusion_expr::ScalarUDF;
use rstest::rstest;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -119,8 +120,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let tester = ScalarUdfTester::new(st_dimension_udf().into(), vec![sedona_type.clone()]);

tester.assert_return_type(DataType::Int8);
Expand Down
3 changes: 1 addition & 2 deletions rust/sedona-functions/src/st_geometrytype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fn infer_geometry_type_name(buf: &[u8]) -> Result<&'static str> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array, ArrayRef};
use datafusion_common::ScalarValue;
use datafusion_expr::ScalarUDF;
use rstest::rstest;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -134,8 +135,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let udf: ScalarUDF = st_geometry_type_udf().into();
let tester = ScalarUdfTester::new(udf, vec![sedona_type]);
tester.assert_return_type(DataType::Utf8);
Expand Down
2 changes: 1 addition & 1 deletion rust/sedona-functions/src/st_haszm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use datafusion_common::error::Result;
use datafusion_expr::{
scalar_doc_sections::DOC_SECTION_OTHER, ColumnarValue, Documentation, Volatility,
};
use geo_traits::GeometryCollectionTrait;
use geo_traits::{Dimensions, GeometryTrait};
use sedona_common::sedona_internal_err;
use sedona_expr::scalar_udf::{SedonaScalarKernel, SedonaScalarUDF};
Expand Down Expand Up @@ -110,7 +111,6 @@ impl SedonaScalarKernel for STHasZm {
fn invoke_scalar(item: &Wkb, dim_index: usize) -> Result<Option<bool>> {
match item.as_type() {
geo_traits::GeometryType::GeometryCollection(collection) => {
use geo_traits::GeometryCollectionTrait;
if collection.num_geometries() == 0 {
Ok(Some(false))
} else {
Expand Down
3 changes: 1 addition & 2 deletions rust/sedona-functions/src/st_isclosed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ fn is_geometry_closed(item: &Wkb) -> Result<bool> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use datafusion_expr::ScalarUDF;
use rstest::rstest;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -140,8 +141,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let tester = ScalarUdfTester::new(st_isclosed_udf().into(), vec![sedona_type.clone()]);

tester.assert_return_type(DataType::Boolean);
Expand Down
3 changes: 1 addition & 2 deletions rust/sedona-functions/src/st_isempty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ fn invoke_scalar(item: &Wkb) -> Result<bool> {
#[cfg(test)]
mod tests {
use arrow_array::{create_array as arrow_array, ArrayRef};
use datafusion_common::ScalarValue;
use datafusion_expr::ScalarUDF;
use rstest::rstest;
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
Expand All @@ -114,8 +115,6 @@ mod tests {

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
use datafusion_common::ScalarValue;

let tester = ScalarUdfTester::new(st_isempty_udf().into(), vec![sedona_type.clone()]);

tester.assert_return_type(DataType::Boolean);
Expand Down
5 changes: 2 additions & 3 deletions rust/sedona-functions/src/st_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ fn populate_wkb_item(item: &mut [u8], x: &f64, y: &f64) {
#[cfg(test)]
mod tests {
use arrow_array::create_array;
use arrow_array::ArrayRef;
use arrow_schema::DataType;
use datafusion_expr::ScalarUDF;
use rstest::rstest;
use sedona_testing::compare::assert_array_equal;
use sedona_testing::{create::create_array, testers::ScalarUdfTester};

use super::*;
Expand All @@ -179,9 +181,6 @@ mod tests {
#[case(DataType::Float64, DataType::Float32)]
#[case(DataType::Float32, DataType::Float32)]
fn udf_invoke(#[case] lhs_type: DataType, #[case] rhs_type: DataType) {
use arrow_array::ArrayRef;
use sedona_testing::compare::assert_array_equal;

let udf = st_point_udf();

let lhs_scalar_null = ScalarValue::Float64(None).cast_to(&lhs_type).unwrap();
Expand Down
3 changes: 1 addition & 2 deletions rust/sedona-geo/src/st_dwithin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ mod tests {
use sedona_schema::datatypes::{WKB_GEOMETRY, WKB_VIEW_GEOMETRY};
use sedona_testing::create::create_scalar;
use sedona_testing::testers::ScalarUdfTester;
use sedona_testing::{compare::assert_array_equal, create::create_array};

use super::*;

Expand All @@ -96,8 +97,6 @@ mod tests {
#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] left_sedona_type: SedonaType,
#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] right_sedona_type: SedonaType,
) {
use sedona_testing::{compare::assert_array_equal, create::create_array};

let udf = SedonaScalarUDF::from_kernel("st_dwithin", st_dwithin_impl());
let tester = ScalarUdfTester::new(
udf.into(),
Expand Down
17 changes: 9 additions & 8 deletions rust/sedona-spatial-join/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ use std::{fmt::Formatter, sync::Arc};
use arrow_schema::SchemaRef;
use datafusion_common::{project_schema, DataFusionError, JoinSide, Result};
use datafusion_execution::{SendableRecordBatchStream, TaskContext};
use datafusion_expr::JoinType;
use datafusion_physical_expr::equivalence::{join_equivalence_properties, ProjectionMapping};
use datafusion_physical_expr::PhysicalExpr;
use datafusion_expr::{JoinType, Operator};
use datafusion_physical_expr::{
equivalence::{join_equivalence_properties, ProjectionMapping},
expressions::{BinaryExpr, Column},
PhysicalExpr,
};
use datafusion_physical_plan::{
execution_plan::EmissionType,
joins::utils::{build_join_schema, check_join_is_valid, ColumnIndex, JoinFilter},
metrics::{ExecutionPlanMetricsSet, MetricsSet},
DisplayAs, DisplayFormatType, ExecutionPlan, ExecutionPlanProperties, PlanProperties,
DisplayAs, DisplayFormatType, ExecutionPlan, ExecutionPlanProperties, Partitioning,
PlanProperties,
};
use parking_lot::Mutex;

Expand All @@ -48,9 +52,6 @@ type BuildProbePlans<'a> = (&'a Arc<dyn ExecutionPlan>, &'a Arc<dyn ExecutionPla
fn extract_equality_conditions(
filter: &JoinFilter,
) -> Vec<(Arc<dyn PhysicalExpr>, Arc<dyn PhysicalExpr>)> {
use datafusion_expr::Operator;
use datafusion_physical_expr::expressions::{BinaryExpr, Column};

let mut equalities = Vec::new();

if let Some(binary_expr) = filter.expression().as_any().downcast_ref::<BinaryExpr>() {
Expand Down Expand Up @@ -269,7 +270,7 @@ impl SpatialJoinExec {
// Replicate HashJoin's symmetric partitioning logic
// HashJoin preserves partitioning from both sides for inner joins
// and from one side for outer joins
use datafusion_physical_plan::Partitioning;

match join_type {
JoinType::Inner | JoinType::Left | JoinType::LeftSemi | JoinType::LeftAnti => {
left.output_partitioning().clone()
Expand Down
Loading