diff --git a/python/sedonadb/tests/functions/test_aggregate.py b/python/sedonadb/tests/functions/test_aggregate.py index 5fddd9ad..6f6344d1 100644 --- a/python/sedonadb/tests/functions/test_aggregate.py +++ b/python/sedonadb/tests/functions/test_aggregate.py @@ -19,16 +19,17 @@ from sedonadb.testing import PostGIS, SedonaDB -def polygonize_fn_suffix(eng): - """Return the appropriate suffix for the polygonize function for the given engine.""" +def agg_fn_suffix(eng): + """Return the appropriate suffix for the aggregate function for the given engine.""" return "" if isinstance(eng, PostGIS) else "_Agg" @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_points(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('POINT (1 2)'), ('POINT (3 4)'), @@ -41,8 +42,9 @@ def test_st_collect_points(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_linestrings(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('LINESTRING (1 2, 3 4)'), ('LINESTRING (5 6, 7 8)'), @@ -55,8 +57,9 @@ def test_st_collect_linestrings(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_polygons(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('POLYGON ((0 0, 1 0, 0 1, 0 0))'), ('POLYGON ((10 10, 11 10, 10 11, 10 10))'), @@ -69,8 +72,9 @@ def test_st_collect_polygons(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_mixed_types(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('POINT (1 2)'), ('LINESTRING (3 4, 5 6)'), @@ -83,10 +87,10 @@ def test_st_collect_mixed_types(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_mixed_dimensions(eng): eng = eng.create_or_skip() - + suffix = agg_fn_suffix(eng) with pytest.raises(Exception, match="mixed dimension geometries"): eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('POINT (1 2)'), ('POINT Z (3 4 5)'), @@ -99,8 +103,9 @@ def test_st_collect_mixed_dimensions(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_all_null(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(geom) FROM ( + f"""SELECT ST_Collect{suffix}(geom) FROM ( VALUES (NULL), (NULL), @@ -113,8 +118,9 @@ def test_st_collect_all_null(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_collect_zero_input(eng): eng = eng.create_or_skip() + suffix = agg_fn_suffix(eng) eng.assert_query_result( - """SELECT ST_Collect(ST_GeomFromText(geom)) AS empty FROM ( + f"""SELECT ST_Collect{suffix}(ST_GeomFromText(geom)) AS empty FROM ( VALUES ('POINT (1 2)') ) AS t(geom) WHERE false""", @@ -125,7 +131,7 @@ def test_st_collect_zero_input(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_polygonize_basic_triangle(eng): eng = eng.create_or_skip() - suffix = polygonize_fn_suffix(eng) + suffix = agg_fn_suffix(eng) eng.assert_query_result( f"""SELECT ST_Polygonize{suffix}(ST_GeomFromText(geom)) FROM ( VALUES @@ -140,7 +146,7 @@ def test_st_polygonize_basic_triangle(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_polygonize_with_nulls(eng): eng = eng.create_or_skip() - suffix = polygonize_fn_suffix(eng) + suffix = agg_fn_suffix(eng) eng.assert_query_result( f"""SELECT ST_Polygonize{suffix}(ST_GeomFromText(geom)) FROM ( VALUES @@ -157,7 +163,7 @@ def test_st_polygonize_with_nulls(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_polygonize_no_polygons_formed(eng): eng = eng.create_or_skip() - suffix = polygonize_fn_suffix(eng) + suffix = agg_fn_suffix(eng) eng.assert_query_result( f"""SELECT ST_Polygonize{suffix}(ST_GeomFromText(geom)) FROM ( VALUES @@ -171,7 +177,7 @@ def test_st_polygonize_no_polygons_formed(eng): @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) def test_st_polygonize_multiple_polygons(eng): eng = eng.create_or_skip() - suffix = polygonize_fn_suffix(eng) + suffix = agg_fn_suffix(eng) eng.assert_query_result( f"""SELECT ST_Polygonize{suffix}(ST_GeomFromText(geom)) FROM ( VALUES @@ -214,7 +220,7 @@ def test_st_polygonize_multiple_polygons(eng): ) def test_st_polygonize_single_geom(eng, geom, expected): eng = eng.create_or_skip() - suffix = polygonize_fn_suffix(eng) + suffix = agg_fn_suffix(eng) eng.assert_query_result( f"""SELECT ST_Polygonize{suffix}(ST_GeomFromText(geom)) FROM ( VALUES ('{geom}') diff --git a/rust/sedona-functions/benches/native-functions.rs b/rust/sedona-functions/benches/native-functions.rs index 80611302..2a68dc48 100644 --- a/rust/sedona-functions/benches/native-functions.rs +++ b/rust/sedona-functions/benches/native-functions.rs @@ -189,14 +189,14 @@ fn criterion_benchmark(c: &mut Criterion) { BenchmarkArgs::ArrayArray(Point, Point), ); - benchmark::aggregate(c, &f, "native", "st_envelope_aggr", Point); - benchmark::aggregate(c, &f, "native", "st_envelope_aggr", LineString(10)); + benchmark::aggregate(c, &f, "native", "st_envelope_agg", Point); + benchmark::aggregate(c, &f, "native", "st_envelope_agg", LineString(10)); - benchmark::aggregate(c, &f, "native", "st_analyze_aggr", Point); - benchmark::aggregate(c, &f, "native", "st_analyze_aggr", LineString(10)); + benchmark::aggregate(c, &f, "native", "st_analyze_agg", Point); + benchmark::aggregate(c, &f, "native", "st_analyze_agg", LineString(10)); - benchmark::aggregate(c, &f, "native", "st_collect", Point); - benchmark::aggregate(c, &f, "native", "st_collect", LineString(10)); + benchmark::aggregate(c, &f, "native", "st_collect_agg", Point); + benchmark::aggregate(c, &f, "native", "st_collect_agg", LineString(10)); } criterion_group!(benches, criterion_benchmark); diff --git a/rust/sedona-functions/src/lib.rs b/rust/sedona-functions/src/lib.rs index 7a7a9585..a6003043 100644 --- a/rust/sedona-functions/src/lib.rs +++ b/rust/sedona-functions/src/lib.rs @@ -22,26 +22,26 @@ mod predicates; mod referencing; pub mod register; mod sd_format; -pub mod st_analyze_aggr; +pub mod st_analyze_agg; mod st_area; mod st_asbinary; mod st_astext; mod st_azimuth; mod st_buffer; mod st_centroid; -mod st_collect; +mod st_collect_agg; mod st_dimension; mod st_dump; mod st_dwithin; pub mod st_envelope; -pub mod st_envelope_aggr; +pub mod st_envelope_agg; pub mod st_flipcoordinates; mod st_geometryn; mod st_geometrytype; mod st_geomfromwkb; mod st_geomfromwkt; mod st_haszm; -pub mod st_intersection_aggr; +pub mod st_intersection_agg; pub mod st_isclosed; mod st_iscollection; pub mod st_isempty; @@ -59,7 +59,7 @@ mod st_srid; mod st_start_point; mod st_transform; mod st_translate; -pub mod st_union_aggr; +pub mod st_union_agg; mod st_xyzm; mod st_xyzm_minmax; mod st_zmflag; diff --git a/rust/sedona-functions/src/register.rs b/rust/sedona-functions/src/register.rs index 68f4ed54..cdae47b8 100644 --- a/rust/sedona-functions/src/register.rs +++ b/rust/sedona-functions/src/register.rs @@ -120,12 +120,12 @@ pub fn default_function_set() -> FunctionSet { register_aggregate_udfs!( function_set, - crate::st_analyze_aggr::st_analyze_aggr_udf, - crate::st_collect::st_collect_udf, - crate::st_envelope_aggr::st_envelope_aggr_udf, - crate::st_intersection_aggr::st_intersection_aggr_udf, + crate::st_analyze_agg::st_analyze_agg_udf, + crate::st_collect_agg::st_collect_agg_udf, + crate::st_envelope_agg::st_envelope_agg_udf, + crate::st_intersection_agg::st_intersection_agg_udf, crate::st_polygonize_agg::st_polygonize_agg_udf, - crate::st_union_aggr::st_union_aggr_udf, + crate::st_union_agg::st_union_agg_udf, ); function_set diff --git a/rust/sedona-functions/src/st_analyze_aggr.rs b/rust/sedona-functions/src/st_analyze_agg.rs similarity index 94% rename from rust/sedona-functions/src/st_analyze_aggr.rs rename to rust/sedona-functions/src/st_analyze_agg.rs index a3c6d8c2..c574ca97 100644 --- a/rust/sedona-functions/src/st_analyze_aggr.rs +++ b/rust/sedona-functions/src/st_analyze_agg.rs @@ -41,40 +41,40 @@ use wkb::reader::Wkb; use crate::executor::WkbExecutor; -/// ST_Analyze_Aggr() aggregate UDF implementation +/// ST_Analyze_Agg() aggregate UDF implementation /// /// This function computes comprehensive statistics for a collection of geometries. /// It returns a struct containing various metrics such as count, min/max coordinates, /// mean size, and geometry type counts. -pub fn st_analyze_aggr_udf() -> SedonaAggregateUDF { +pub fn st_analyze_agg_udf() -> SedonaAggregateUDF { SedonaAggregateUDF::new( - "st_analyze_aggr", - vec![Arc::new(STAnalyzeAggr {})], + "st_analyze_agg", + vec![Arc::new(STAnalyzeAgg {})], Volatility::Immutable, - Some(st_analyze_aggr_doc()), + Some(st_analyze_agg_doc()), ) } -fn st_analyze_aggr_doc() -> Documentation { +fn st_analyze_agg_doc() -> Documentation { Documentation::builder( DOC_SECTION_OTHER, "Return Return the statistics of geometries for geom.", - "ST_Analyze_Aggr (A: Geometry)", + "ST_Analyze_Agg (A: Geometry)", ) .with_argument("geom", "geometry: Input geometry or geography") .with_sql_example(" - SELECT ST_Analyze_Aggr(ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)'))") + SELECT ST_Analyze_Agg(ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)'))") .build() } -/// ST_Analyze_Aggr() implementation -pub fn st_analyze_aggr_impl() -> SedonaAccumulatorRef { - Arc::new(STAnalyzeAggr {}) +/// ST_Analyze_Agg() implementation +pub fn st_analyze_agg_impl() -> SedonaAccumulatorRef { + Arc::new(STAnalyzeAgg {}) } #[derive(Debug)] -struct STAnalyzeAggr {} +struct STAnalyzeAgg {} -impl SedonaAccumulator for STAnalyzeAggr { +impl SedonaAccumulator for STAnalyzeAgg { fn return_type(&self, args: &[SedonaType]) -> Result> { let output_fields = Self::output_fields(); @@ -103,7 +103,7 @@ impl SedonaAccumulator for STAnalyzeAggr { } } -impl STAnalyzeAggr { +impl STAnalyzeAgg { fn create_float64_array(value: Option) -> Float64Array { match value { Some(v) => Float64Array::from(vec![v]), @@ -202,7 +202,7 @@ impl STAnalyzeAggr { }; // Define output fields - let fields = STAnalyzeAggr::output_fields(); + let fields = STAnalyzeAgg::output_fields(); // Create arrays with proper null handling let values = vec![ @@ -390,7 +390,7 @@ impl Accumulator for AnalyzeAccumulator { } fn evaluate(&mut self) -> Result { - let field_array_pairs = STAnalyzeAggr::output_arrays(self.stats.clone()); + let field_array_pairs = STAnalyzeAgg::output_arrays(self.stats.clone()); // Create the struct array with field values let struct_array = StructArray::from(field_array_pairs); @@ -498,8 +498,8 @@ mod test { #[rstest] fn basic_analyze_cases(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_analyze_aggr_udf(); - udaf.add_kernel(st_analyze_aggr_impl()); + let mut udaf = st_analyze_agg_udf(); + udaf.add_kernel(st_analyze_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -538,8 +538,8 @@ mod test { #[rstest] fn analyze_linestring(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_analyze_aggr_udf(); - udaf.add_kernel(st_analyze_aggr_impl()); + let mut udaf = st_analyze_agg_udf(); + udaf.add_kernel(st_analyze_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -578,8 +578,8 @@ mod test { #[rstest] fn analyze_polygon(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_analyze_aggr_udf(); - udaf.add_kernel(st_analyze_aggr_impl()); + let mut udaf = st_analyze_agg_udf(); + udaf.add_kernel(st_analyze_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -620,8 +620,8 @@ mod test { fn analyze_mixed_geometries( #[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType, ) { - let mut udaf = st_analyze_aggr_udf(); - udaf.add_kernel(st_analyze_aggr_impl()); + let mut udaf = st_analyze_agg_udf(); + udaf.add_kernel(st_analyze_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -662,8 +662,8 @@ mod test { #[rstest] fn analyze_empty_input(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_analyze_aggr_udf(); - udaf.add_kernel(st_analyze_aggr_impl()); + let mut udaf = st_analyze_agg_udf(); + udaf.add_kernel(st_analyze_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); diff --git a/rust/sedona-functions/src/st_collect.rs b/rust/sedona-functions/src/st_collect_agg.rs similarity index 94% rename from rust/sedona-functions/src/st_collect.rs rename to rust/sedona-functions/src/st_collect_agg.rs index 7eed4b3e..dfd91940 100644 --- a/rust/sedona-functions/src/st_collect.rs +++ b/rust/sedona-functions/src/st_collect_agg.rs @@ -42,26 +42,26 @@ use sedona_schema::{ matchers::ArgMatcher, }; -/// ST_Collect() aggregate UDF implementation +/// ST_Collect_Agg() aggregate UDF implementation /// /// An implementation of envelope (bounding shape) calculation. -pub fn st_collect_udf() -> SedonaAggregateUDF { +pub fn st_collect_agg_udf() -> SedonaAggregateUDF { SedonaAggregateUDF::new( - "st_collect", + "st_collect_agg", vec![Arc::new(STCollectAggr {})], Volatility::Immutable, - Some(st_collect_doc()), + Some(st_collect_agg_doc()), ) } -fn st_collect_doc() -> Documentation { +fn st_collect_agg_doc() -> Documentation { Documentation::builder( DOC_SECTION_OTHER, "Return the entire envelope boundary of all geometries in geom", - "ST_Collect (geom: Geometry)", + "ST_Collect_Agg (geom: Geometry)", ) .with_argument("geom", "geometry: Input geometry or geography") - .with_sql_example("SELECT ST_Collect(ST_GeomFromWKT('MULTIPOINT (0 1, 10 11)'))") + .with_sql_example("SELECT ST_Collect_Agg(ST_GeomFromWKT('MULTIPOINT (0 1, 10 11)'))") .build() } @@ -136,7 +136,7 @@ impl CollectionAccumulator { let count_usize = self.count.try_into().unwrap(); if self.unique_dimensions.len() != 1 { - return exec_err!("Can't ST_Collect() mixed dimension geometries"); + return exec_err!("Can't ST_Collect_Agg() mixed dimension geometries"); } let dimensions = *self.unique_dimensions.iter().next().unwrap(); @@ -169,7 +169,7 @@ impl CollectionAccumulator { out[0..WKB_HEADER_SIZE].copy_from_slice(&new_header); Ok(Some(out)) } else { - sedona_internal_err!("Unexpected internal state in ST_Collect()") + sedona_internal_err!("Unexpected internal state in ST_Collect_Agg()") } } } @@ -179,7 +179,7 @@ impl Accumulator for CollectionAccumulator { let item_ref = if let Some(item_ref) = self.item.as_mut() { item_ref } else { - return sedona_internal_err!("Unexpected internal state in ST_Collect()"); + return sedona_internal_err!("Unexpected internal state in ST_Collect_Agg()"); }; let arg_types = [self.input_type.clone()]; @@ -247,7 +247,7 @@ impl Accumulator for CollectionAccumulator { let item_ref = if let Some(item_ref) = self.item.as_mut() { item_ref } else { - return sedona_internal_err!("Unexpected internal state in ST_Collect()"); + return sedona_internal_err!("Unexpected internal state in ST_Collect_Agg()"); }; let mut geometry_types_iter = as_string_array(&states[0])?.into_iter(); @@ -306,14 +306,15 @@ mod test { #[test] fn udf_metadata() { - let udf: AggregateUDF = st_collect_udf().into(); - assert_eq!(udf.name(), "st_collect"); + let udf: AggregateUDF = st_collect_agg_udf().into(); + assert_eq!(udf.name(), "st_collect_agg"); assert!(udf.documentation().is_some()); } #[rstest] fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let tester = AggregateUdfTester::new(st_collect_udf().into(), vec![sedona_type.clone()]); + let tester = + AggregateUdfTester::new(st_collect_agg_udf().into(), vec![sedona_type.clone()]); assert_eq!(tester.return_type().unwrap(), WKB_GEOMETRY); // Finite point input with nulls @@ -367,7 +368,7 @@ mod test { let err = tester.aggregate_wkt(batches).unwrap_err(); assert_eq!( err.message(), - "Can't ST_Collect() mixed dimension geometries" + "Can't ST_Collect_Agg() mixed dimension geometries" ); } } diff --git a/rust/sedona-functions/src/st_envelope_aggr.rs b/rust/sedona-functions/src/st_envelope_agg.rs similarity index 91% rename from rust/sedona-functions/src/st_envelope_aggr.rs rename to rust/sedona-functions/src/st_envelope_agg.rs index 159d0171..c077ac01 100644 --- a/rust/sedona-functions/src/st_envelope_aggr.rs +++ b/rust/sedona-functions/src/st_envelope_agg.rs @@ -38,33 +38,33 @@ use sedona_schema::{ matchers::ArgMatcher, }; -/// ST_Envelope_Aggr() aggregate UDF implementation +/// ST_Envelope_Agg() aggregate UDF implementation /// /// An implementation of envelope (bounding shape) calculation. -pub fn st_envelope_aggr_udf() -> SedonaAggregateUDF { +pub fn st_envelope_agg_udf() -> SedonaAggregateUDF { SedonaAggregateUDF::new( - "st_envelope_aggr", - vec![Arc::new(STEnvelopeAggr {})], + "st_envelope_agg", + vec![Arc::new(STEnvelopeAgg {})], Volatility::Immutable, - Some(st_envelope_aggr_doc()), + Some(st_envelope_agg_doc()), ) } -fn st_envelope_aggr_doc() -> Documentation { +fn st_envelope_agg_doc() -> Documentation { Documentation::builder( DOC_SECTION_OTHER, "Return the entire envelope boundary of all geometries in geom", - "ST_Envelope_Aggr (geom: Geometry)", + "ST_Envelope_Agg (geom: Geometry)", ) .with_argument("geom", "geometry: Input geometry or geography") - .with_sql_example("SELECT ST_Envelope_Aggr(ST_GeomFromWKT('MULTIPOINT (0 1, 10 11)'))") + .with_sql_example("SELECT ST_Envelope_Agg(ST_GeomFromWKT('MULTIPOINT (0 1, 10 11)'))") .build() } #[derive(Debug)] -struct STEnvelopeAggr {} +struct STEnvelopeAgg {} -impl SedonaAccumulator for STEnvelopeAggr { +impl SedonaAccumulator for STEnvelopeAgg { fn return_type(&self, args: &[SedonaType]) -> Result> { let matcher = ArgMatcher::new(vec![ArgMatcher::is_geometry()], WKB_GEOMETRY); matcher.match_args(args) @@ -189,15 +189,15 @@ mod test { #[test] fn udf_metadata() { - let udf: AggregateUDF = st_envelope_aggr_udf().into(); - assert_eq!(udf.name(), "st_envelope_aggr"); + let udf: AggregateUDF = st_envelope_agg_udf().into(); + assert_eq!(udf.name(), "st_envelope_agg"); assert!(udf.documentation().is_some()); } #[rstest] fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { let tester = - AggregateUdfTester::new(st_envelope_aggr_udf().into(), vec![sedona_type.clone()]); + AggregateUdfTester::new(st_envelope_agg_udf().into(), vec![sedona_type.clone()]); assert_eq!(tester.return_type().unwrap(), WKB_GEOMETRY); // Finite input with nulls diff --git a/rust/sedona-functions/src/st_intersection_aggr.rs b/rust/sedona-functions/src/st_intersection_agg.rs similarity index 77% rename from rust/sedona-functions/src/st_intersection_aggr.rs rename to rust/sedona-functions/src/st_intersection_agg.rs index 3c7212d1..fe4aa4f8 100644 --- a/rust/sedona-functions/src/st_intersection_aggr.rs +++ b/rust/sedona-functions/src/st_intersection_agg.rs @@ -23,31 +23,31 @@ use sedona_schema::{ matchers::ArgMatcher, }; -/// ST_Intersection_Aggr() aggregate UDF implementation +/// ST_Intersection_Agg() aggregate UDF implementation /// /// An implementation of intersection calculation. -pub fn st_intersection_aggr_udf() -> SedonaAggregateUDF { +pub fn st_intersection_agg_udf() -> SedonaAggregateUDF { SedonaAggregateUDF::new_stub( - "st_intersection_aggr", + "st_intersection_agg", ArgMatcher::new( vec![ArgMatcher::is_geometry_or_geography()], SedonaType::Wkb(Edges::Planar, None), ), Volatility::Immutable, - Some(st_intersection_aggr_doc()), + Some(st_intersection_agg_doc()), ) } -fn st_intersection_aggr_doc() -> Documentation { +fn st_intersection_agg_doc() -> Documentation { Documentation::builder( DOC_SECTION_OTHER, "Return the polygon intersection of all polygons in geom.", - "ST_Intersection_Aggr (A: Geometry, B: Geometry)", + "ST_Intersection_Agg (A: Geometry, B: Geometry)", ) .with_argument("geom", "geometry: Input geometry or geography") .with_sql_example( " - SELECT ST_Intersection_Aggr(ST_GeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')), + SELECT ST_Intersection_Agg(ST_GeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')), ST_GeomFromText('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))')", ) .build() @@ -61,8 +61,8 @@ mod test { #[test] fn udf_metadata() { - let udf: AggregateUDF = st_intersection_aggr_udf().into(); - assert_eq!(udf.name(), "st_intersection_aggr"); + let udf: AggregateUDF = st_intersection_agg_udf().into(); + assert_eq!(udf.name(), "st_intersection_agg"); assert!(udf.documentation().is_some()); } } diff --git a/rust/sedona-functions/src/st_union_aggr.rs b/rust/sedona-functions/src/st_union_agg.rs similarity index 79% rename from rust/sedona-functions/src/st_union_aggr.rs rename to rust/sedona-functions/src/st_union_agg.rs index 764ffab0..63f5195c 100644 --- a/rust/sedona-functions/src/st_union_aggr.rs +++ b/rust/sedona-functions/src/st_union_agg.rs @@ -23,29 +23,29 @@ use sedona_schema::{ matchers::ArgMatcher, }; -/// ST_Union_Aggr() aggregate UDF implementation +/// ST_Union_Agg() aggregate UDF implementation /// /// An implementation of union calculation. -pub fn st_union_aggr_udf() -> SedonaAggregateUDF { +pub fn st_union_agg_udf() -> SedonaAggregateUDF { SedonaAggregateUDF::new_stub( - "st_union_aggr", + "st_union_agg", ArgMatcher::new( vec![ArgMatcher::is_geometry_or_geography()], SedonaType::Wkb(Edges::Planar, None), ), Volatility::Immutable, - Some(st_union_aggr_doc()), + Some(st_union_agg_doc()), ) } -fn st_union_aggr_doc() -> Documentation { +fn st_union_agg_doc() -> Documentation { Documentation::builder( DOC_SECTION_OTHER, "Return the geometric union of all geometries in the input column.", - "ST_Union_Aggr (geom: Geometry)", + "ST_Union_Agg (geom: Geometry)", ) .with_argument("geom", "geometry: Input geometry or geography") - .with_sql_example("SELECT ST_Union_Aggr(ST_GeomFromWKT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'))") + .with_sql_example("SELECT ST_Union_Agg(ST_GeomFromWKT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'))") .build() } @@ -57,8 +57,8 @@ mod test { #[test] fn udf_metadata() { - let udf: AggregateUDF = st_union_aggr_udf().into(); - assert_eq!(udf.name(), "st_union_aggr"); + let udf: AggregateUDF = st_union_agg_udf().into(); + assert_eq!(udf.name(), "st_union_agg"); assert!(udf.documentation().is_some()); } } diff --git a/rust/sedona-geo/benches/geo-functions.rs b/rust/sedona-geo/benches/geo-functions.rs index 2630e6c9..16259edf 100644 --- a/rust/sedona-geo/benches/geo-functions.rs +++ b/rust/sedona-geo/benches/geo-functions.rs @@ -76,9 +76,9 @@ fn criterion_benchmark_aggr(c: &mut Criterion) { f.add_aggregate_udf_kernel(name, kernel).unwrap(); } - // st_intersection_aggr would need its own configuration because most of the generated + // st_intersection_agg would need its own configuration because most of the generated // polygons would not intersect and result in empty output almost immediately - benchmark::aggregate(c, &f, "geo", "st_union_aggr", Polygon(10)); + benchmark::aggregate(c, &f, "geo", "st_union_agg", Polygon(10)); } criterion_group!(benches, criterion_benchmark); diff --git a/rust/sedona-geo/src/lib.rs b/rust/sedona-geo/src/lib.rs index 0a5224ab..f06a98b1 100644 --- a/rust/sedona-geo/src/lib.rs +++ b/rust/sedona-geo/src/lib.rs @@ -20,10 +20,10 @@ mod st_area; mod st_centroid; mod st_distance; mod st_dwithin; -mod st_intersection_aggr; +mod st_intersection_agg; mod st_intersects; mod st_length; mod st_line_interpolate_point; mod st_perimeter; -mod st_union_aggr; +mod st_union_agg; pub mod to_geo; diff --git a/rust/sedona-geo/src/register.rs b/rust/sedona-geo/src/register.rs index 9041c2dc..b28239f0 100644 --- a/rust/sedona-geo/src/register.rs +++ b/rust/sedona-geo/src/register.rs @@ -17,9 +17,9 @@ use sedona_expr::aggregate_udf::SedonaAccumulatorRef; use sedona_expr::scalar_udf::ScalarKernelRef; -use crate::st_intersection_aggr::st_intersection_aggr_impl; +use crate::st_intersection_agg::st_intersection_agg_impl; use crate::st_line_interpolate_point::st_line_interpolate_point_impl; -use crate::st_union_aggr::st_union_aggr_impl; +use crate::st_union_agg::st_union_agg_impl; use crate::{ st_area::st_area_impl, st_centroid::st_centroid_impl, st_distance::st_distance_impl, st_dwithin::st_dwithin_impl, st_intersects::st_intersects_impl, st_length::st_length_impl, @@ -41,7 +41,7 @@ pub fn scalar_kernels() -> Vec<(&'static str, ScalarKernelRef)> { pub fn aggregate_kernels() -> Vec<(&'static str, SedonaAccumulatorRef)> { vec![ - ("st_intersection_aggr", st_intersection_aggr_impl()), - ("st_union_aggr", st_union_aggr_impl()), + ("st_intersection_agg", st_intersection_agg_impl()), + ("st_union_agg", st_union_agg_impl()), ] } diff --git a/rust/sedona-geo/src/st_intersection_aggr.rs b/rust/sedona-geo/src/st_intersection_agg.rs similarity index 95% rename from rust/sedona-geo/src/st_intersection_aggr.rs rename to rust/sedona-geo/src/st_intersection_agg.rs index b9cad44b..72fafb91 100644 --- a/rust/sedona-geo/src/st_intersection_aggr.rs +++ b/rust/sedona-geo/src/st_intersection_agg.rs @@ -35,15 +35,15 @@ use wkb::writer::write_geometry; use wkb::Endianness; use wkb::{reader::Wkb, writer::WriteOptions}; -/// ST_Intersection_Aggr() implementation -pub fn st_intersection_aggr_impl() -> SedonaAccumulatorRef { - Arc::new(STIntersectionAggr {}) +/// ST_Intersection_Agg() implementation +pub fn st_intersection_agg_impl() -> SedonaAccumulatorRef { + Arc::new(STIntersectionAgg {}) } #[derive(Debug)] -struct STIntersectionAggr {} +struct STIntersectionAgg {} -impl SedonaAccumulator for STIntersectionAggr { +impl SedonaAccumulator for STIntersectionAgg { fn return_type(&self, args: &[SedonaType]) -> Result> { let matcher = ArgMatcher::new(vec![ArgMatcher::is_geometry()], WKB_GEOMETRY); matcher.match_args(args) @@ -227,7 +227,7 @@ impl Accumulator for IntersectionAccumulator { mod test { use super::*; use rstest::rstest; - use sedona_functions::st_intersection_aggr::st_intersection_aggr_udf; + use sedona_functions::st_intersection_agg::st_intersection_agg_udf; use sedona_schema::datatypes::WKB_VIEW_GEOMETRY; use sedona_testing::{ compare::assert_scalar_equal_wkb_geometry_topologically, testers::AggregateUdfTester, @@ -235,8 +235,8 @@ mod test { #[rstest] fn polygon_polygon_cases(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_intersection_aggr_udf(); - udaf.add_kernel(st_intersection_aggr_impl()); + let mut udaf = st_intersection_agg_udf(); + udaf.add_kernel(st_intersection_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); assert_eq!(tester.return_type().unwrap(), WKB_GEOMETRY); @@ -300,8 +300,8 @@ mod test { fn polygon_multipolygon_cases( #[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType, ) { - let mut udaf = st_intersection_aggr_udf(); - udaf.add_kernel(st_intersection_aggr_impl()); + let mut udaf = st_intersection_agg_udf(); + udaf.add_kernel(st_intersection_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -348,8 +348,8 @@ mod test { fn multipolygon_multipolygon_cases( #[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType, ) { - let mut udaf = st_intersection_aggr_udf(); - udaf.add_kernel(st_intersection_aggr_impl()); + let mut udaf = st_intersection_agg_udf(); + udaf.add_kernel(st_intersection_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); diff --git a/rust/sedona-geo/src/st_union_aggr.rs b/rust/sedona-geo/src/st_union_agg.rs similarity index 96% rename from rust/sedona-geo/src/st_union_aggr.rs rename to rust/sedona-geo/src/st_union_agg.rs index 2462e48c..5b780bd0 100644 --- a/rust/sedona-geo/src/st_union_aggr.rs +++ b/rust/sedona-geo/src/st_union_agg.rs @@ -35,15 +35,15 @@ use wkb::writer::write_geometry; use wkb::Endianness; use wkb::{reader::Wkb, writer::WriteOptions}; -/// ST_Union_Aggr() implementation -pub fn st_union_aggr_impl() -> SedonaAccumulatorRef { - Arc::new(STUnionAggr {}) +/// ST_Union_Agg() implementation +pub fn st_union_agg_impl() -> SedonaAccumulatorRef { + Arc::new(STUnionAgg {}) } #[derive(Debug)] -struct STUnionAggr {} +struct STUnionAgg {} -impl SedonaAccumulator for STUnionAggr { +impl SedonaAccumulator for STUnionAgg { fn return_type(&self, args: &[SedonaType]) -> Result> { let matcher = ArgMatcher::new(vec![ArgMatcher::is_geometry()], WKB_GEOMETRY); matcher.match_args(args) @@ -221,7 +221,7 @@ impl Accumulator for UnionAccumulator { mod test { use super::*; use rstest::rstest; - use sedona_functions::st_union_aggr::st_union_aggr_udf; + use sedona_functions::st_union_agg::st_union_agg_udf; use sedona_schema::datatypes::WKB_VIEW_GEOMETRY; use sedona_testing::{ compare::assert_scalar_equal_wkb_geometry_topologically, testers::AggregateUdfTester, @@ -229,8 +229,8 @@ mod test { #[rstest] fn polygon_polygon_cases(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) { - let mut udaf = st_union_aggr_udf(); - udaf.add_kernel(st_union_aggr_impl()); + let mut udaf = st_union_agg_udf(); + udaf.add_kernel(st_union_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); assert_eq!(tester.return_type().unwrap(), WKB_GEOMETRY); @@ -292,8 +292,8 @@ mod test { fn polygon_multipolygon_cases( #[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType, ) { - let mut udaf = st_union_aggr_udf(); - udaf.add_kernel(st_union_aggr_impl()); + let mut udaf = st_union_agg_udf(); + udaf.add_kernel(st_union_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); @@ -340,8 +340,8 @@ mod test { fn multipolygon_multipolygon_cases( #[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType, ) { - let mut udaf = st_union_aggr_udf(); - udaf.add_kernel(st_union_aggr_impl()); + let mut udaf = st_union_agg_udf(); + udaf.add_kernel(st_union_agg_impl()); let tester = AggregateUdfTester::new(udaf.into(), vec![sedona_type.clone()]); diff --git a/rust/sedona-spatial-join/src/index/build_side_collector.rs b/rust/sedona-spatial-join/src/index/build_side_collector.rs index 5efc6c35..6fafa441 100644 --- a/rust/sedona-spatial-join/src/index/build_side_collector.rs +++ b/rust/sedona-spatial-join/src/index/build_side_collector.rs @@ -23,7 +23,7 @@ use datafusion_execution::{memory_pool::MemoryReservation, SendableRecordBatchSt use datafusion_physical_plan::metrics::{self, ExecutionPlanMetricsSet, MetricBuilder}; use futures::StreamExt; use sedona_expr::statistics::GeoStatistics; -use sedona_functions::st_analyze_aggr::AnalyzeAccumulator; +use sedona_functions::st_analyze_agg::AnalyzeAccumulator; use sedona_schema::datatypes::WKB_GEOMETRY; use crate::{ diff --git a/rust/sedona-spatial-join/src/stream.rs b/rust/sedona-spatial-join/src/stream.rs index 67b73064..cb8a4e3d 100644 --- a/rust/sedona-spatial-join/src/stream.rs +++ b/rust/sedona-spatial-join/src/stream.rs @@ -27,7 +27,7 @@ use futures::stream::StreamExt; use futures::{ready, task::Poll}; use parking_lot::Mutex; use sedona_common::sedona_internal_err; -use sedona_functions::st_analyze_aggr::AnalyzeAccumulator; +use sedona_functions::st_analyze_agg::AnalyzeAccumulator; use sedona_schema::datatypes::WKB_GEOMETRY; use std::collections::HashMap; use std::ops::Range;