You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2024/01/07 22:36:01 UTC

(sedona) branch add_more_snowflake_funcs created (now 2a752fffe)

This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a change to branch add_more_snowflake_funcs
in repository https://gitbox.apache.org/repos/asf/sedona.git


      at 2a752fffe Add new functions

This branch includes the following new commits:

     new 2a752fffe Add new functions

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(sedona) 01/01: Add new functions

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch add_more_snowflake_funcs
in repository https://gitbox.apache.org/repos/asf/sedona.git

commit 2a752fffeda73b8ed89eceab979f39fe11f35223
Author: Jia Yu <ji...@apache.org>
AuthorDate: Sun Jan 7 14:35:48 2024 -0800

    Add new functions
---
 .../java/org/apache/sedona/common/Functions.java   |  19 +-
 .../org/apache/sedona/common/utils/GeomUtils.java  |   2 +-
 .../sedona/snowflake/snowsql/TestFunctions.java    |   9 +
 .../org/apache/sedona/snowflake/snowsql/UDFs.java  | 221 ++++++++++++++++++++-
 .../apache/sedona/snowflake/snowsql/UDFsV2.java    | 194 +++++++++++++++++-
 5 files changed, 438 insertions(+), 7 deletions(-)

diff --git a/common/src/main/java/org/apache/sedona/common/Functions.java b/common/src/main/java/org/apache/sedona/common/Functions.java
index ff86d91c3..f1fe7c7f1 100644
--- a/common/src/main/java/org/apache/sedona/common/Functions.java
+++ b/common/src/main/java/org/apache/sedona/common/Functions.java
@@ -463,7 +463,20 @@ public class Functions {
     }
 
     public static boolean isValid(Geometry geometry) {
-        return new IsValidOp(geometry).isValid();
+        return isValid(geometry, OGC_SFS_VALIDITY);
+    }
+
+    public static boolean isValid(Geometry geom, int flags) {
+        IsValidOp isValidOp = new IsValidOp(geom);
+
+        // Set the validity model based on flags
+        if (flags == ESRI_VALIDITY) {
+            isValidOp.setSelfTouchingRingFormingHoleValid(true);
+        } else {
+            isValidOp.setSelfTouchingRingFormingHoleValid(false);
+        }
+
+        return isValidOp.isValid();
     }
 
     public static Geometry addPoint(Geometry linestring, Geometry point) {
@@ -1268,11 +1281,11 @@ public class Functions {
         return GeomUtils.toDegrees(angleInRadian);
     }
 
-    public static Double hausdorffDistance(Geometry g1, Geometry g2, double densityFrac) throws Exception {
+    public static Double hausdorffDistance(Geometry g1, Geometry g2, double densityFrac) {
         return GeomUtils.getHausdorffDistance(g1, g2, densityFrac);
     }
 
-    public static Double hausdorffDistance(Geometry g1, Geometry g2) throws Exception{
+    public static Double hausdorffDistance(Geometry g1, Geometry g2) {
         return GeomUtils.getHausdorffDistance(g1, g2, -1);
     }
 
diff --git a/common/src/main/java/org/apache/sedona/common/utils/GeomUtils.java b/common/src/main/java/org/apache/sedona/common/utils/GeomUtils.java
index fc16349dc..9a4d57e91 100644
--- a/common/src/main/java/org/apache/sedona/common/utils/GeomUtils.java
+++ b/common/src/main/java/org/apache/sedona/common/utils/GeomUtils.java
@@ -516,7 +516,7 @@ public class GeomUtils {
         return DiscreteFrechetDistance.distance(g1, g2);
     }
 
-    public static Double getHausdorffDistance(Geometry g1, Geometry g2, double densityFrac) throws Exception {
+    public static Double getHausdorffDistance(Geometry g1, Geometry g2, double densityFrac) {
         if (g1.isEmpty() || g2.isEmpty()) return 0.0;
         DiscreteHausdorffDistance hausdorffDistanceObj = new DiscreteHausdorffDistance(g1, g2);
         if (densityFrac != -1) {
diff --git a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java
index 8a652c35e..ee42404c7 100644
--- a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java
+++ b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java
@@ -251,6 +251,15 @@ public class TestFunctions extends TestBase {
         );
     }
     @Test
+    public void test_ST_Force2D() {
+        registerUDF("ST_PointZ", double.class, double.class, double.class);
+        registerUDF("ST_Force2D", byte[].class);
+        verifySqlSingleRes(
+                "select sedona.ST_AsText(sedona.ST_Force2D(sedona.ST_POINTZ(1, 2, 3)))",
+                "POINT (1 2)"
+        );
+    }
+    @Test
     public void test_ST_GeoHash() {
         registerUDF("ST_GeoHash", byte[].class, int.class);
         verifySqlSingleRes(
diff --git a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
index 2752a55d5..ff3d51b76 100644
--- a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
+++ b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFs.java
@@ -15,6 +15,7 @@ package org.apache.sedona.snowflake.snowsql;
 
 import org.apache.sedona.common.Constructors;
 import org.apache.sedona.common.Functions;
+import org.apache.sedona.common.FunctionsGeoTools;
 import org.apache.sedona.common.Predicates;
 import org.apache.sedona.common.enums.FileDataSplitter;
 import org.apache.sedona.common.sphere.Haversine;
@@ -37,6 +38,10 @@ import java.io.IOException;
  */
 public class UDFs {
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static String GeometryType(byte[] geometry) {
+        return Functions.geometryTypeWithMeasured(GeometrySerde.deserialize(geometry));
+    }
     @UDFAnnotations.ParamMeta(argNames = {"linestring", "point", "position"})
     public static byte[] ST_AddPoint(byte[] linestring, byte[] point, int position) {
         return GeometrySerde.serialize(
@@ -48,6 +53,36 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "a", "b", "c", "d", "e", "f", "g", "h", "i", "xOff", "yOff", "zOff"})
+    public static byte[] ST_Affine(byte[] geometry, double a, double b, double c, double d, double e, double f, double g, double h, double i, double xOff, double yOff,
+            double zOff) {
+        return GeometrySerde.serialize(
+                Functions.affine(GeometrySerde.deserialize(geometry), a, b, c, d, e, f, g, h, i, xOff, yOff, zOff)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "a", "b", "c", "d", "e", "f", "xOff", "yOff"})
+    public static byte[] ST_Affine(byte[] geometry, double a, double b, double d, double e, double xOff, double yOff) {
+        return GeometrySerde.serialize(
+                Functions.affine(GeometrySerde.deserialize(geometry), a, b, d, e, xOff, yOff)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2"})
+    public static double ST_Angle(byte[] geom1, byte[] geom2) {
+        return Functions.angle(GeometrySerde.deserialize(geom1), GeometrySerde.deserialize(geom2));
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "geom3"})
+    public static double ST_Angle(byte[] geom1, byte[] geom2, byte[] geom3) {
+        return Functions.angle(GeometrySerde.deserialize(geom1), GeometrySerde.deserialize(geom2), GeometrySerde.deserialize(geom3));
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "geom3", "geom4"})
+    public static double ST_Angle(byte[] geom1, byte[] geom2, byte[] geom3, byte[] geom4) {
+        return Functions.angle(GeometrySerde.deserialize(geom1), GeometrySerde.deserialize(geom2), GeometrySerde.deserialize(geom3), GeometrySerde.deserialize(geom4));
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static double ST_Area(byte[] geometry) {
         return Functions.area(
@@ -114,6 +149,15 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static byte[] ST_BoundingDiagonal(byte[] geometry) {
+        return GeometrySerde.serialize(
+                Functions.boundingDiagonal(
+                        GeometrySerde.deserialize(geometry)
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "radius"})
     public static byte[] ST_Buffer(byte[] geometry, double radius) {
         return GeometrySerde.serialize(
@@ -142,6 +186,16 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry1", "geometry2"})
+    public static byte[] ST_ClosestPoint(byte[] geom1, byte[] geom2) {
+        return GeometrySerde.serialize(
+                Functions.closestPoint(
+                        GeometrySerde.deserialize(geom1),
+                        GeometrySerde.deserialize(geom2)
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static byte[] ST_CollectionExtract(byte[] geometry) throws IOException {
         return GeometrySerde.serialize(
@@ -190,7 +244,10 @@ public class UDFs {
                 GeometrySerde.deserialize(rightGeometry)
         );
     }
-
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static int ST_CoordDim(byte[] geometry) {
+        return Functions.nDims(GeometrySerde.deserialize(geometry));
+    }
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static byte[] ST_ConvexHull(byte[] geometry) {
         return GeometrySerde.serialize(
@@ -199,7 +256,6 @@ public class UDFs {
                 )
         );
     }
-
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"})
     public static boolean ST_CoveredBy(byte[] leftGeometry, byte[] rightGeometry) {
         return Predicates.coveredBy(
@@ -224,6 +280,11 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"angleInRadian"})
+    public static double ST_Degrees(double angleInRadian) {
+        return Functions.degrees(angleInRadian);
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"})
     public static byte[] ST_Difference(byte[] leftGeometry, byte[] rightGeometry) {
         return GeometrySerde.serialize(
@@ -234,6 +295,13 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static Integer ST_Dimension(byte[] geometry) {
+        return Functions.dimension(
+                GeometrySerde.deserialize(geometry)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"})
     public static boolean ST_Disjoint(byte[] leftGeometry, byte[] rightGeometry) {
         return Predicates.disjoint(
@@ -321,6 +389,15 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static byte[] ST_Force2D(byte[] geometry) {
+        return GeometrySerde.serialize(
+                Functions.force2D(
+                        GeometrySerde.deserialize(geometry)
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "precision"})
     public static String ST_GeoHash(byte[] geometry, int precision) {
         return Functions.geohash(
@@ -405,6 +482,25 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2"})
+    public static double ST_HausdorffDistance(byte[] geom1, byte[] geom2)
+    {
+        return Functions.hausdorffDistance(
+                GeometrySerde.deserialize(geom1),
+                GeometrySerde.deserialize(geom2)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "densifyFrac"})
+    public static double ST_HausdorffDistance(byte[] geom1, byte[] geom2, double densifyFrac)
+    {
+        return Functions.hausdorffDistance(
+                GeometrySerde.deserialize(geom1),
+                GeometrySerde.deserialize(geom2),
+                densifyFrac
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "n"})
     public static byte[] ST_InteriorRingN(byte[] geometry, int n) {
         return GeometrySerde.serialize(
@@ -440,6 +536,13 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static boolean ST_IsCollection(byte[] geometry) {
+        return Functions.isCollection(
+                GeometrySerde.deserialize(geometry)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static boolean ST_IsEmpty(byte[] geometry) {
         return Functions.isEmpty(
@@ -468,6 +571,27 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "flags"})
+    public static boolean ST_IsValid(byte[] geometry, int flags) {
+        return Functions.isValid(
+                GeometrySerde.deserialize(geometry), flags
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static String ST_IsValidReason(byte[] geometry) {
+        return Functions.isValidReason(
+                GeometrySerde.deserialize(geometry)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "flags"})
+    public static String ST_IsValidReason(byte[] geometry, int flags) {
+        return Functions.isValidReason(
+                GeometrySerde.deserialize(geometry), flags
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static double ST_Length(byte[] geometry) {
         return Functions.length(
@@ -501,6 +625,14 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geom", "point"})
+    public static double ST_LineLocatePoint(byte[] geom, byte[] point) {
+        return Functions.lineLocatePoint(
+                GeometrySerde.deserialize(geom),
+                GeometrySerde.deserialize(point)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"})
     public static byte[] ST_LineMerge(byte[] geometry) {
         return GeometrySerde.serialize(
@@ -527,7 +659,38 @@ public class UDFs {
                 )
         );
     }
+    @UDFAnnotations.ParamMeta(argNames = {"point1", "point2"})
+    public static byte[] ST_MakeLine(byte[] geom1, byte[] geom2) {
+        return GeometrySerde.serialize(
+                Functions.makeLine(GeometrySerde.deserialize(geom1), GeometrySerde.deserialize(geom2))
+        );
+    }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometryCollection"})
+    public static byte[] ST_MakeLine(byte[] geometry) {
+        return GeometrySerde.serialize(
+                Functions.makeLine(GeometrySerde.deserialize2List(geometry))
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"x", "y"})
+    public static byte[] ST_MakePoint(double x, double y) {
+        return GeometrySerde.serialize(
+                Constructors.makePoint(x, y, null, null)
+        );
+    }
+    @UDFAnnotations.ParamMeta(argNames = {"x", "y", "z"})
+    public static byte[] ST_MakePoint(double x, double y, double z) {
+        return GeometrySerde.serialize(
+                Constructors.makePoint(x, y, z, null)
+        );
+    }
+    @UDFAnnotations.ParamMeta(argNames = {"x", "y", "z", "m"})
+    public static byte[] ST_MakePoint(double x, double y, double z, double m) {
+        return GeometrySerde.serialize(
+                Constructors.makePoint(x, y, z, m)
+        );
+    }
     @UDFAnnotations.ParamMeta(argNames = {"wkt", "srid"})
     public static byte[] ST_MLineFromText(String wkt, int srid) throws ParseException {
         return GeometrySerde.serialize(
@@ -715,6 +878,15 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "srid"})
+    public static byte[] ST_Polygon(byte[] geometry, int srid) {
+        return GeometrySerde.serialize(
+                Functions.makepolygonWithSRID(
+                        GeometrySerde.deserialize(geometry), srid
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"minX", "minY", "maxX", "maxY"})
     public static byte[] ST_PolygonFromEnvelope(double minX, double minY, double maxX, double maxY) {
         return GeometrySerde.serialize(
@@ -912,6 +1084,34 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"})
+    public static byte[] ST_VoronoiPolygons(byte[] geometry) {
+        return GeometrySerde.serialize(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserialize(geometry), 0.0, null)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "tolerance"})
+    public static byte[] ST_VoronoiPolygons(byte[] geometry, double tolerance) {
+        return GeometrySerde.serialize(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserialize(geometry), tolerance, null)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "extent"})
+    public static byte[] ST_VoronoiPolygons(byte[] geometry, byte[] extent) {
+        return GeometrySerde.serialize(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserialize(geometry), 0.0, GeometrySerde.deserialize(extent))
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "tolerance", "extent"})
+    public static byte[] ST_VoronoiPolygons(byte[] geometry, double tolerance, byte[] extent) {
+        return GeometrySerde.serialize(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserialize(geometry), tolerance, GeometrySerde.deserialize(extent))
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"})
     public static boolean ST_Within(byte[] leftGeometry, byte[] rightGeometry) {
         return Predicates.within(
@@ -1015,6 +1215,23 @@ public class UDFs {
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geomA", "geomB", "distance"})
+    public static boolean ST_DWithin(byte[] geomA, byte[] geomB, double distance) {
+        return Predicates.dWithin(
+                GeometrySerde.deserialize(geomA),
+                GeometrySerde.deserialize(geomB),
+                distance
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geomA", "geomB"})
+    public static double ST_FrechetDistance(byte[] geomA, byte[] geomB) {
+        return Functions.frechetDistance(
+                GeometrySerde.deserialize(geomA),
+                GeometrySerde.deserialize(geomB)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geom", "zValue"})
     public static byte[] ST_Force3D(byte[] geom, double zValue) {
         WKBWriter writer = new WKBWriter(3);
diff --git a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFsV2.java b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFsV2.java
index 2ca729eaf..9b9ceb00a 100644
--- a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFsV2.java
+++ b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/UDFsV2.java
@@ -14,6 +14,7 @@
 package org.apache.sedona.snowflake.snowsql;
 
 import org.apache.sedona.common.Functions;
+import org.apache.sedona.common.FunctionsGeoTools;
 import org.apache.sedona.common.Predicates;
 import org.apache.sedona.common.sphere.Haversine;
 import org.apache.sedona.common.sphere.Spheroid;
@@ -33,6 +34,11 @@ import java.io.IOException;
  */
 public class UDFsV2
 {
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"},
+            argTypes = {"Geometry"})
+    public static String GeometryType(String geometry) {
+        return Functions.geometryTypeWithMeasured(GeometrySerde.deserGeoJson(geometry));
+    }
     @UDFAnnotations.ParamMeta(argNames = {"linestring", "point", "position"},
             argTypes = {"Geometry", "Geometry", "int"},
             returnTypes = "Geometry")
@@ -46,6 +52,40 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "a", "b", "c", "d", "e", "f", "g", "h", "i", "xOff", "yOff", "zOff"},
+            argTypes = {"Geometry", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double"},
+            returnTypes = "Geometry")
+    public static String ST_Affine(String geometry, double a, double b, double c, double d, double e, double f, double g, double h, double i, double xOff, double yOff,
+            double zOff) {
+        return GeometrySerde.serGeoJson(
+                Functions.affine(GeometrySerde.deserGeoJson(geometry), a, b, c, d, e, f, g, h, i, xOff, yOff, zOff)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "a", "b", "c", "d", "e", "f", "xOff", "yOff"},
+            argTypes = {"Geometry", "double", "double", "double", "double", "double", "double"},
+            returnTypes = "Geometry")
+    public static String ST_Affine(String geometry, double a, double b, double d, double e, double xOff, double yOff) {
+        return GeometrySerde.serGeoJson(
+                Functions.affine(GeometrySerde.deserGeoJson(geometry), a, b, d, e, xOff, yOff)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2"}, argTypes = {"Geometry", "Geometry"})
+    public static double ST_Angle(String geom1, String geom2) {
+        return Functions.angle(GeometrySerde.deserGeoJson(geom1), GeometrySerde.deserGeoJson(geom2));
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "geom3"}, argTypes = {"Geometry", "Geometry", "Geometry"})
+    public static double ST_Angle(String geom1, String geom2, String geom3) {
+        return Functions.angle(GeometrySerde.deserGeoJson(geom1), GeometrySerde.deserGeoJson(geom2), GeometrySerde.deserGeoJson(geom3));
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "geom3", "geom4"}, argTypes = {"Geometry", "Geometry", "Geometry", "Geometry"})
+    public static double ST_Angle(String geom1, String geom2, String geom3, String geom4) {
+        return Functions.angle(GeometrySerde.deserGeoJson(geom1), GeometrySerde.deserGeoJson(geom2), GeometrySerde.deserGeoJson(geom3), GeometrySerde.deserGeoJson(geom4));
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"},
             argTypes = {"Geometry"})
     public static double ST_Area(String geometry) {
@@ -122,6 +162,15 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
+    public static String ST_BoundingDiagonal(String geometry) {
+        return GeometrySerde.serGeoJson(
+                Functions.boundingDiagonal(
+                        GeometrySerde.deserGeoJson(geometry)
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "radius"}, argTypes = {"Geometry", "double"}, returnTypes = "Geometry")
     public static String ST_Buffer(String geometry, double radius) {
         return GeometrySerde.serGeoJson(
@@ -150,6 +199,16 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry1", "geometry2"}, argTypes = {"Geometry", "Geometry"}, returnTypes = "Geometry")
+    public static String ST_ClosestPoint(String geom1, String geom2) {
+        return GeometrySerde.serGeoJson(
+                Functions.closestPoint(
+                        GeometrySerde.deserGeoJson(geom1),
+                        GeometrySerde.deserGeoJson(geom2)
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
     public static String ST_CollectionExtract(String geometry) throws IOException {
         return GeometrySerde.serGeoJson(
@@ -198,7 +257,10 @@ public class UDFsV2
                 GeometrySerde.deserGeoJson(rightGeometry)
         );
     }
-
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
+    public static int ST_CoordDim(String geometry) {
+        return Functions.nDims(GeometrySerde.deserGeoJson(geometry));
+    }
     @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
     public static String ST_ConvexHull(String geometry) {
         return GeometrySerde.serGeoJson(
@@ -242,6 +304,13 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
+    public static Integer ST_Dimension(String geometry) {
+        return Functions.dimension(
+                GeometrySerde.deserGeoJson(geometry)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"}, argTypes = {"Geometry", "Geometry"})
     public static boolean ST_Disjoint(String leftGeometry, String rightGeometry) {
         return Predicates.disjoint(
@@ -363,6 +432,25 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2"}, argTypes = {"Geometry", "Geometry"})
+    public static double ST_HausdorffDistance(String geom1, String geom2)
+    {
+        return Functions.hausdorffDistance(
+                GeometrySerde.deserGeoJson(geom1),
+                GeometrySerde.deserGeoJson(geom2)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geom1", "geom2", "densifyFrac"}, argTypes = {"Geometry", "Geometry", "double"})
+    public static double ST_HausdorffDistance(String geom1, String geom2, double densifyFrac)
+    {
+        return Functions.hausdorffDistance(
+                GeometrySerde.deserGeoJson(geom1),
+                GeometrySerde.deserGeoJson(geom2),
+                densifyFrac
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "n"}, argTypes = {"Geometry", "int"}, returnTypes = "Geometry")
     public static String ST_InteriorRingN(String geometry, int n) {
         return GeometrySerde.serGeoJson(
@@ -398,6 +486,13 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
+    public static boolean ST_IsCollection(String geometry) {
+        return Functions.isCollection(
+                GeometrySerde.deserGeoJson(geometry)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
     public static boolean ST_IsEmpty(String geometry) {
         return Functions.isEmpty(
@@ -426,6 +521,27 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "flags"}, argTypes = {"Geometry", "int"})
+    public static boolean ST_IsValid(String geometry, int flags) {
+        return Functions.isValid(
+                GeometrySerde.deserGeoJson(geometry), flags
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
+    public static String ST_IsValidReason(String geometry) {
+        return Functions.isValidReason(
+                GeometrySerde.deserGeoJson(geometry)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "flags"}, argTypes = {"Geometry", "int"})
+    public static String ST_IsValidReason(String geometry, int flags) {
+        return Functions.isValidReason(
+                GeometrySerde.deserGeoJson(geometry), flags
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"})
     public static double ST_Length(String geometry) {
         return Functions.length(
@@ -452,6 +568,14 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geom", "point"}, argTypes = {"Geometry", "Geometry"})
+    public static double ST_LineLocatePoint(String geom, String point) {
+        return Functions.lineLocatePoint(
+                GeometrySerde.deserGeoJson(geom),
+                GeometrySerde.deserGeoJson(point)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
     public static String ST_LineMerge(String geometry) {
         return GeometrySerde.serGeoJson(
@@ -472,6 +596,20 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"point1", "point2"}, argTypes = {"Geometry", "Geometry"}, returnTypes = "Geometry")
+    public static String ST_MakeLine(String geom1, String geom2) {
+        return GeometrySerde.serGeoJson(
+                Functions.makeLine(GeometrySerde.deserGeoJson(geom1), GeometrySerde.deserGeoJson(geom2))
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometryCollection"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
+    public static String ST_MakeLine(String geometry) {
+        return GeometrySerde.serGeoJson(
+                Functions.makeLine(GeometrySerde.deserGeoJson2List(geometry))
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"shell"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
     public static String ST_MakePolygon(String shell) {
         return GeometrySerde.serGeoJson(
@@ -603,6 +741,15 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "srid"}, argTypes = {"Geometry", "int"}, returnTypes = "Geometry")
+    public static String ST_Polygon(String geometry, int srid) {
+        return GeometrySerde.serGeoJson(
+                Functions.makepolygonWithSRID(
+                        GeometrySerde.deserGeoJson(geometry), srid
+                )
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geometry", "precisionScale"}, argTypes = {"Geometry", "int"}, returnTypes = "Geometry")
     public static String ST_PrecisionReduce(String geometry, int precisionScale) {
         return GeometrySerde.serGeoJson(
@@ -786,6 +933,34 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geometry"}, argTypes = {"Geometry"}, returnTypes = "Geometry")
+    public static String ST_VoronoiPolygons(String geometry) {
+        return GeometrySerde.serGeoJson(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserGeoJson(geometry), 0.0, null)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "tolerance"}, argTypes = {"Geometry", "double"}, returnTypes = "Geometry")
+    public static String ST_VoronoiPolygons(String geometry, double tolerance) {
+        return GeometrySerde.serGeoJson(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserGeoJson(geometry), tolerance, null)
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "extent"}, argTypes = {"Geometry", "Geometry"}, returnTypes = "Geometry")
+    public static String ST_VoronoiPolygons(String geometry, String extent) {
+        return GeometrySerde.serGeoJson(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserGeoJson(geometry), 0.0, GeometrySerde.deserGeoJson(extent))
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geometry", "tolerance", "extent"}, argTypes = {"Geometry", "double", "Geometry"}, returnTypes = "Geometry")
+    public static String ST_VoronoiPolygons(String geometry, double tolerance, String extent) {
+        return GeometrySerde.serGeoJson(
+                FunctionsGeoTools.voronoiPolygons(GeometrySerde.deserGeoJson(geometry), tolerance, GeometrySerde.deserGeoJson(extent))
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"leftGeometry", "rightGeometry"}, argTypes = {"Geometry", "Geometry"})
     public static boolean ST_Within(String leftGeometry, String rightGeometry) {
         return Predicates.within(
@@ -889,6 +1064,23 @@ public class UDFsV2
         );
     }
 
+    @UDFAnnotations.ParamMeta(argNames = {"geomA", "geomB", "distance"}, argTypes = {"Geometry", "Geometry", "double"})
+    public static boolean ST_DWithin(String geomA, String geomB, double distance) {
+        return Predicates.dWithin(
+                GeometrySerde.deserGeoJson(geomA),
+                GeometrySerde.deserGeoJson(geomB),
+                distance
+        );
+    }
+
+    @UDFAnnotations.ParamMeta(argNames = {"geomA", "geomB"}, argTypes = {"Geometry", "Geometry"})
+    public static double ST_FrechetDistance(String geomA, String geomB) {
+        return Functions.frechetDistance(
+                GeometrySerde.deserGeoJson(geomA),
+                GeometrySerde.deserGeoJson(geomB)
+        );
+    }
+
     @UDFAnnotations.ParamMeta(argNames = {"geom", "zValue"}, argTypes = {"Geometry", "double"}, returnTypes = "Geometry")
     public static String ST_Force3D(String geom, double zValue) {
         return GeometrySerde.serGeoJson(