yutannihilation commented on code in PR #275:
URL: https://github.com/apache/sedona-db/pull/275#discussion_r2507483758
##########
rust/sedona-functions/src/st_setsrid.rs:
##########
@@ -227,6 +230,105 @@ fn determine_return_type(
sedona_internal_err!("Unexpected argument types: {}, {}", args[0], args[1])
}
+/// [SedonaScalarKernel] wrapper that handles the SRID argument for
constructors like ST_Point
+#[derive(Debug)]
+pub(crate) struct SRIDifiedKernel {
+ inner: ScalarKernelRef,
+}
+
+impl SRIDifiedKernel {
+ pub(crate) fn new(inner: ScalarKernelRef) -> Self {
+ Self { inner }
+ }
+}
+
+impl SedonaScalarKernel for SRIDifiedKernel {
+ fn return_type_from_args_and_scalars(
+ &self,
+ args: &[SedonaType],
+ scalar_args: &[Option<&ScalarValue>],
+ ) -> Result<Option<SedonaType>> {
+ // args should consist of the original args and one extra arg for
+ // specifying CRS. So, first, validate the length and separate these.
+ //
+ // [arg0, arg1, ..., crs_arg];
+ // ^^^^^^^^^^^^^^^
+ // orig_args
+ let orig_args_len = match (args.len(), scalar_args.len()) {
+ (0, 0) => return Ok(None),
+ (l1, l2) if l1 == l2 => l1 - 1,
+ _ => return sedona_internal_err!("Arg types and arg values have
different lengths"),
+ };
+
+ let orig_args = &args[..orig_args_len];
+ let orig_scalar_args = &scalar_args[..orig_args_len];
Review Comment:
Thanks, sounds good to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]