This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new 11e2993 chore: Refactor `with_aliases` to a more builder-like pattern
(#178)
11e2993 is described below
commit 11e299392b4d5bd17281dd4892ece764b8138795
Author: Peter Nguyen <[email protected]>
AuthorDate: Fri Oct 3 08:01:53 2025 -0700
chore: Refactor `with_aliases` to a more builder-like pattern (#178)
---
rust/sedona-expr/src/scalar_udf.rs | 18 ++++++------------
rust/sedona-functions/src/st_asbinary.rs | 6 +++---
rust/sedona-functions/src/st_astext.rs | 6 +++---
rust/sedona-functions/src/st_geomfromwkt.rs | 12 ++++++------
4 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/rust/sedona-expr/src/scalar_udf.rs
b/rust/sedona-expr/src/scalar_udf.rs
index 32b9e0d..7f4c187 100644
--- a/rust/sedona-expr/src/scalar_udf.rs
+++ b/rust/sedona-expr/src/scalar_udf.rs
@@ -139,19 +139,13 @@ impl SedonaScalarUDF {
}
}
- pub fn new_with_aliases(
- name: &str,
- kernels: Vec<ScalarKernelRef>,
- volatility: Volatility,
- documentation: Option<Documentation>,
- aliases: Vec<String>,
- ) -> SedonaScalarUDF {
- let signature = Signature::user_defined(volatility);
+ /// Add aliases to an existing SedonaScalarUDF
+ pub fn with_aliases(self, aliases: Vec<String>) -> SedonaScalarUDF {
Self {
- name: name.to_string(),
- signature,
- kernels,
- documentation,
+ name: self.name,
+ signature: self.signature,
+ kernels: self.kernels,
+ documentation: self.documentation,
aliases,
}
}
diff --git a/rust/sedona-functions/src/st_asbinary.rs
b/rust/sedona-functions/src/st_asbinary.rs
index f819ce4..84e35ca 100644
--- a/rust/sedona-functions/src/st_asbinary.rs
+++ b/rust/sedona-functions/src/st_asbinary.rs
@@ -28,13 +28,13 @@ use sedona_schema::{datatypes::SedonaType,
matchers::ArgMatcher};
///
/// An implementation of WKB writing using GeoRust's wkt crate.
pub fn st_asbinary_udf() -> SedonaScalarUDF {
- SedonaScalarUDF::new_with_aliases(
+ let udf = SedonaScalarUDF::new(
"st_asbinary",
vec![Arc::new(STAsBinary {})],
Volatility::Immutable,
Some(st_asbinary_doc()),
- vec!["st_aswkb".to_string()],
- )
+ );
+ udf.with_aliases(vec!["st_aswkb".to_string()])
}
fn st_asbinary_doc() -> Documentation {
diff --git a/rust/sedona-functions/src/st_astext.rs
b/rust/sedona-functions/src/st_astext.rs
index 701a066..cbe6043 100644
--- a/rust/sedona-functions/src/st_astext.rs
+++ b/rust/sedona-functions/src/st_astext.rs
@@ -30,13 +30,13 @@ use sedona_schema::{datatypes::SedonaType,
matchers::ArgMatcher};
///
/// An implementation of WKT writing using GeoRust's wkt crate.
pub fn st_astext_udf() -> SedonaScalarUDF {
- SedonaScalarUDF::new_with_aliases(
+ let udf = SedonaScalarUDF::new(
"st_astext",
vec![Arc::new(STAsText {})],
Volatility::Immutable,
Some(st_astext_doc()),
- vec!["st_aswkt".to_string()],
- )
+ );
+ udf.with_aliases(vec!["st_aswkt".to_string()])
}
fn st_astext_doc() -> Documentation {
diff --git a/rust/sedona-functions/src/st_geomfromwkt.rs
b/rust/sedona-functions/src/st_geomfromwkt.rs
index d7bb3ea..b35d628 100644
--- a/rust/sedona-functions/src/st_geomfromwkt.rs
+++ b/rust/sedona-functions/src/st_geomfromwkt.rs
@@ -39,15 +39,15 @@ use crate::executor::WkbExecutor;
/// An implementation of WKT reading using GeoRust's wkt crate.
/// See [`st_geogfromwkt_udf`] for the corresponding geography function.
pub fn st_geomfromwkt_udf() -> SedonaScalarUDF {
- SedonaScalarUDF::new_with_aliases(
+ let udf = SedonaScalarUDF::new(
"st_geomfromwkt",
vec![Arc::new(STGeoFromWKT {
out_type: WKB_GEOMETRY,
})],
Volatility::Immutable,
Some(doc("ST_GeomFromWKT", "Geometry")),
- vec!["st_geomfromtext".to_string()],
- )
+ );
+ udf.with_aliases(vec!["st_geomfromtext".to_string()])
}
/// ST_GeogFromWKT() UDF implementation
@@ -55,15 +55,15 @@ pub fn st_geomfromwkt_udf() -> SedonaScalarUDF {
/// An implementation of WKT reading using GeoRust's wkt crate.
/// See [`st_geomfromwkt_udf`] for the corresponding geometry function.
pub fn st_geogfromwkt_udf() -> SedonaScalarUDF {
- SedonaScalarUDF::new_with_aliases(
+ let udf = SedonaScalarUDF::new(
"st_geogfromwkt",
vec![Arc::new(STGeoFromWKT {
out_type: WKB_GEOGRAPHY,
})],
Volatility::Immutable,
Some(doc("ST_GeogFromWKT", "Geography")),
- vec!["st_geogfromtext".to_string()],
- )
+ );
+ udf.with_aliases(vec!["st_geogfromtext".to_string()])
}
fn doc(name: &str, out_type_name: &str) -> Documentation {