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 2023/09/22 07:37:14 UTC

[sedona] branch H3 created (now 2a40f7de8)

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

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


      at 2a40f7de8 Add H3 functions

This branch includes the following new commits:

     new 2a40f7de8 Add H3 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 H3 functions

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

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

commit 2a40f7de89381139ca15ecfabab4ce142c63e3f9
Author: Jia Yu <ji...@apache.org>
AuthorDate: Fri Sep 22 00:36:58 2023 -0700

    Add H3 functions
---
 common/pom.xml                                     |   4 +
 .../java/org/apache/sedona/common/Functions.java   | 113 ++++++++-
 .../org/apache/sedona/common/utils/H3Utils.java    | 270 +++++++++++++++++++++
 .../org/apache/sedona/common/FunctionsTest.java    | 160 +++++++++---
 .../java/org/apache/sedona/common/H3UtilTest.java  | 242 ++++++++++++++++++
 docs/api/flink/Function.md                         | 121 +++++++++
 docs/api/sql/Function.md                           | 122 ++++++++++
 .../main/java/org/apache/sedona/flink/Catalog.java |   4 +
 .../apache/sedona/flink/expressions/Functions.java | 154 +++++++-----
 .../java/org/apache/sedona/flink/FunctionTest.java | 127 +++++++---
 pom.xml                                            |   6 +
 python/sedona/sql/st_functions.py                  |  73 +++++-
 python/tests/sql/test_function.py                  |  55 ++++-
 .../scala/org/apache/sedona/sql/UDF/Catalog.scala  |   4 +
 .../sql/sedona_sql/expressions/Functions.scala     | 225 +++++++++--------
 .../expressions/InferredExpression.scala           |  38 ++-
 .../sql/sedona_sql/expressions/st_functions.scala  |  16 ++
 .../apache/sedona/sql/dataFrameAPITestScala.scala  |  51 +++-
 .../sedona/sql/functions/STH3Functions.scala       | 146 +++++++++++
 19 files changed, 1674 insertions(+), 257 deletions(-)

diff --git a/common/pom.xml b/common/pom.xml
index 9e7f4a6a4..97a460b47 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -81,6 +81,10 @@
             <groupId>com.google.geometry</groupId>
             <artifactId>s2-geometry</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.uber</groupId>
+            <artifactId>h3</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.esotericsoftware</groupId>
             <artifactId>kryo</artifactId>
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 2324b509c..a5ce8585b 100644
--- a/common/src/main/java/org/apache/sedona/common/Functions.java
+++ b/common/src/main/java/org/apache/sedona/common/Functions.java
@@ -14,12 +14,15 @@
 package org.apache.sedona.common;
 
 import com.google.common.geometry.S2CellId;
+import com.uber.h3core.exceptions.H3Exception;
+
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.sedona.common.geometryObjects.Circle;
 import org.apache.sedona.common.subDivide.GeometrySubDivider;
 import org.apache.sedona.common.utils.GeomUtils;
 import org.apache.sedona.common.utils.GeometryGeoHashEncoder;
 import org.apache.sedona.common.utils.GeometrySplitter;
+import org.apache.sedona.common.utils.H3Utils;
 import org.apache.sedona.common.utils.S2Utils;
 import org.locationtech.jts.algorithm.MinimumBoundingCircle;
 import org.locationtech.jts.algorithm.hull.ConcaveHull;
@@ -52,6 +55,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.Collection;
 import java.util.stream.Collectors;
 
 import static com.google.common.geometry.S2.DBL_EPSILON;
@@ -580,6 +586,99 @@ public class Functions {
         return S2Utils.roundCellsToSameLevel(new ArrayList<>(cellIds), level).stream().map(S2CellId::id).collect(Collectors.toList()).toArray(new Long[cellIds.size()]);
     }
 
+    /**
+     * cover the geometry with H3 cells
+     * @param input the input geometry
+     * @param level the resolution of h3 cells
+     * @param fullCover whether enforce full cover or not.
+     * @return
+     */
+    public static Long[] h3CellIDs(Geometry input, int level, boolean fullCover) {
+        if (level < 0 || level > 15) {
+            throw new IllegalArgumentException("level must be between 0 and 15");
+        }
+        HashSet<Long> cellIds = new HashSet<>();
+        // first flat all GeometryCollection implementations into single Geometry types (Polygon, LineString, Point)
+        List<Geometry> geoms = GeomUtils.extractGeometryCollection(input);
+        for (Geometry geom : geoms) {
+            if (geom instanceof Polygon) {
+                cellIds.addAll(H3Utils.polygonToCells((Polygon) geom, level, fullCover));
+            } else if (geom instanceof LineString) {
+                cellIds.addAll(H3Utils.lineStringToCells((LineString) geom, level, fullCover));
+            } else if (geom instanceof Point){
+                cellIds.add(H3Utils.coordinateToCell(geom.getCoordinate(), level));
+            } else {
+                // if not type of polygon, point or lienSting, we cover its MBR
+                cellIds.addAll(H3Utils.polygonToCells((Polygon)geom.getEnvelope(), level, fullCover));
+            }
+        }
+        return cellIds.toArray(new Long[0]);
+    }
+
+    /**
+     * return the distance between 2 cells, if the native h3 function doesn't work, use our approximation function for shortest path and use the size - 1 as distance
+     * @param cell1 source cell
+     * @param cell2 destination cell
+     * @return
+     */
+    public static long h3CellDistance(long cell1, long cell2) {
+        int resolution = H3Utils.h3.getResolution(cell1);
+        if (resolution != H3Utils.h3.getResolution(cell2)) {
+            throw new IllegalArgumentException("The argument cells should be of the same resolution");
+        }
+        try {
+            return H3Utils.h3.gridDistance(cell1, cell2);
+        } catch (H3Exception e) {
+            // approximate if the original function hit error
+            return H3Utils.approxPathCells(
+                    H3Utils.cellToCoordinate(cell1),
+                    H3Utils.cellToCoordinate(cell2),
+                    resolution,
+                    true
+            ).size() - 1;
+        }
+    }
+
+    /**
+     * get the neighbor cells of the input cell by h3.gridDisk function
+     * @param cell: original cell
+     * @param k: the k number of rings spread from the original cell
+     * @param exactDistance: if exactDistance is true, it will only return the cells on the exact kth ring, else will return all 0 - kth neighbors
+     * @return
+     */
+    public static Long[] h3KRing(long cell, int k, boolean exactDistance) {
+        Set<Long> cells = new LinkedHashSet<>(H3Utils.h3.gridDisk(cell, k));
+        if (exactDistance && k > 0) {
+            List<Long> tbdCells = H3Utils.h3.gridDisk(cell, k - 1);
+            tbdCells.forEach(cells::remove);
+        }
+        return cells.toArray(new Long[0]);
+    }
+
+    /**
+     * get the neighbor cells of the input cell by h3.gridDisk function
+     * @param cells: the set of cells
+     * @return Multiple Polygons reversed
+     */
+    public static Geometry h3ToGeom(long[] cells) {
+        GeometryFactory geomFactory = new GeometryFactory();
+        Collection<Long> h3 = Arrays.stream(cells).boxed().collect(Collectors.toList());
+        return geomFactory.createMultiPolygon(
+                H3Utils.h3.cellsToMultiPolygon(h3, true).stream().map(
+                        shellHoles -> {
+                            List<LinearRing> rings = shellHoles.stream().map(
+                                    shell -> geomFactory.createLinearRing(shell.stream().map(latLng -> new Coordinate(latLng.lng, latLng.lat)).toArray(Coordinate[]::new))
+                            ).collect(Collectors.toList());
+                            LinearRing shell = rings.remove(0);
+                            if (rings.isEmpty()) {
+                                return geomFactory.createPolygon(shell);
+                            } else {
+                                return geomFactory.createPolygon(shell, rings.toArray(new LinearRing[0]));
+                            }
+                        }
+                ).toArray(Polygon[]::new)
+        );
+    }
 
     // create static function named simplifyPreserveTopology
     public static Geometry simplifyPreserveTopology(Geometry geometry, double distanceTolerance) {
@@ -660,12 +759,12 @@ public class Functions {
     }
 
     public static Geometry makeLine(Geometry geom1, Geometry geom2) {
-       Geometry[] geoms = new Geometry[]{geom1, geom2};
-       return makeLine(geoms);
+        Geometry[] geoms = new Geometry[]{geom1, geom2};
+        return makeLine(geoms);
     }
 
     public static Geometry makeLine(Geometry[] geoms) {
-        ArrayList<Coordinate> coordinates = new ArrayList<>();      
+        ArrayList<Coordinate> coordinates = new ArrayList<>();
         for (Geometry geom : geoms) {
             if (geom instanceof Point || geom instanceof MultiPoint || geom instanceof LineString) {
                 for (Coordinate coord : geom.getCoordinates()) {
@@ -676,7 +775,7 @@ public class Functions {
                 throw new IllegalArgumentException("ST_MakeLine only supports Point, MultiPoint and LineString geometries");
             }
         }
-        
+
         Coordinate[] coords = coordinates.toArray(new Coordinate[0]);
         return GEOMETRY_FACTORY.createLineString(coords);
     }
@@ -715,7 +814,7 @@ public class Functions {
         }
         return geom;
     }
-    
+
     public static Geometry createMultiGeometry(Geometry[] geometries) {
         if (geometries.length > 1){
             return GEOMETRY_FACTORY.buildGeometry(Arrays.asList(geometries));
@@ -902,7 +1001,7 @@ public class Functions {
     }
 
     public static Geometry force3D(Geometry geometry) {
-       return GeomUtils.get3DGeom(geometry, 0.0);
+        return GeomUtils.get3DGeom(geometry, 0.0);
     }
 
     public static Integer nRings(Geometry geometry) throws Exception {
@@ -940,7 +1039,7 @@ public class Functions {
     }
 
     public static Geometry affine(Geometry 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) {
+            double zOff) {
         if (!geometry.isEmpty()) {
             GeomUtils.affineGeom(geometry, a, b, c, d, e, f, g, h, i, xOff, yOff, zOff);
         }
diff --git a/common/src/main/java/org/apache/sedona/common/utils/H3Utils.java b/common/src/main/java/org/apache/sedona/common/utils/H3Utils.java
new file mode 100644
index 000000000..6c72b7859
--- /dev/null
+++ b/common/src/main/java/org/apache/sedona/common/utils/H3Utils.java
@@ -0,0 +1,270 @@
+package org.apache.sedona.common.utils;
+
+import com.uber.h3core.H3Core;
+import com.uber.h3core.exceptions.H3Exception;
+import com.uber.h3core.util.LatLng;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.Polygon;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class H3Utils
+{
+    public static H3Core h3;
+    public static Map<Integer, Double> cellSizeMap;
+
+    public static class H3UtilException extends RuntimeException {
+        public H3UtilException(Throwable cause) {
+            super(cause);
+        }
+
+        public H3UtilException(String message) {
+            super(message);
+        }
+
+        public H3UtilException(String message, Throwable cause) {
+            super(message, cause);
+        }
+    }
+
+    static {
+        try {
+            h3 = H3Core.newInstance();
+        } catch (IOException e) {
+            throw new H3UtilException(e);
+        }
+        // init cellSizeMap
+        cellSizeMap = new HashMap<>();
+        cellSizeMap.put(0, 1257.1651279870703);
+        cellSizeMap.put(1, 415.1068893923832);
+        cellSizeMap.put(2, 147.84174424387626);
+        cellSizeMap.put(3, 54.530253595150185);
+        cellSizeMap.put(4, 20.426305676421265);
+        cellSizeMap.put(5, 7.693156379723934);
+        cellSizeMap.put(6, 2.9039922554770365);
+        cellSizeMap.put(7, 1.097050477001042);
+        cellSizeMap.put(8, 0.4145696618254594);
+        cellSizeMap.put(9, 0.15668127143434735);
+        cellSizeMap.put(10, 0.059218394287200805);
+        cellSizeMap.put(11, 0.022382219491694798);
+        cellSizeMap.put(12, 0.008459648046313144);
+        cellSizeMap.put(13, 0.0031974550140400557);
+        cellSizeMap.put(14, 0.0012085926447938334);
+        cellSizeMap.put(15, 0.0004567448929842399);
+    }
+
+    public static LatLng coordindateToLatLng(Coordinate coordinate) {
+        return new LatLng(coordinate.getY(), coordinate.getX());
+    }
+
+    public static Coordinate cellToCoordinate(long cell) {
+        LatLng latLng = h3.cellToLatLng(cell);
+        return new Coordinate(latLng.lng, latLng.lat);
+    }
+
+    public static long coordinateToCell(Coordinate coordinate, int level) {
+        return h3.latLngToCell(
+                coordinate.getY(),
+                coordinate.getX(),
+                level
+        );
+    }
+
+    public static List<Long> polygonToCells(Polygon polygon, int level, boolean fullCover) {
+        try {
+            List<LatLng> shell = Arrays.stream(polygon.getExteriorRing().getCoordinates()).map(H3Utils::coordindateToLatLng).collect(Collectors.toList());
+            List<List<LatLng>> holes = new ArrayList<>();
+            for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
+                holes.add(
+                        Arrays.stream(polygon.getInteriorRingN(i).getCoordinates()).map(H3Utils::coordindateToLatLng).collect(Collectors.toList())
+                );
+            }
+            // H3 polyfill only include hexagons with centroid within the polygon, we fix by generating the neighbors for the cells.
+            List<Long> internalCells = h3.polygonToCells(
+                    shell,
+                    holes.isEmpty() ? null : holes,
+                    level
+            );
+            // if the internal cell is empty, means no cell with centroid within, we'll use centroid to add a seed
+            if (internalCells.isEmpty()) {
+                internalCells.add(
+                        coordinateToCell(polygon.getCentroid().getCoordinate(), level)
+                );
+            }
+            if (fullCover) {
+                // H3 polyfill only include hexagons with centroid within the polygon, we add augmentation to guarantee full coverage.
+                Set<Long> cells = new HashSet<>();
+                // this augment shouldn't be required with cells covering shells, just in case we add them
+                internalCells.forEach(
+                        cell -> cells.addAll(h3.gridDisk(cell, 1))
+                );
+                // further augment by adding the shell and holes cover cells
+                cells.addAll(
+                        lineStringToCells(polygon.getExteriorRing(), level, true)
+                );
+                for (int it = 0;it < polygon.getNumInteriorRing(); it++) {
+                    LineString hole = polygon.getInteriorRingN(it);
+                    cells.addAll(
+                            lineStringToCells(hole, level, true)
+                    );
+                }
+                return new ArrayList<>(cells);
+            } else {
+                return internalCells;
+            }
+        } catch (H3Exception e) {
+            throw new H3UtilException(String.format("fail to cover the polygon %s with error %s", GeomUtils.getWKT(polygon), e.getMessage()), e);
+        }
+    }
+
+    public static double latLngDistance(double lat1, double lat2, double lon1,
+                                  double lon2) {
+
+        final int R = 6371; // Radius of the earth
+
+        double latDistance = Math.toRadians(lat2 - lat1);
+        double lonDistance = Math.toRadians(lon2 - lon1);
+        double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2)
+                + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2))
+                * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2);
+        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+        return R * c;
+    }
+
+    public static List<Long> approxPathCells(Coordinate sc, Coordinate ec, int level, boolean safe) {
+        double approxDistance = latLngDistance(sc.y, ec.y, sc.x, ec.x);
+        int itCellNum = Math.max((int) (approxDistance / cellSizeMap.get(level) * 3), 1);
+        double xUnit = (ec.getX() - sc.getX()) / itCellNum;
+        double yUnit = (ec.getY() - sc.getY()) / itCellNum;
+        // keep order of cells
+        Set<Long> cells = new LinkedHashSet<>();
+        for (int it = 0;it <= itCellNum; ++it) {
+            cells.add(coordinateToCell(new Coordinate(sc.getX() + xUnit * it, sc.getY() + yUnit * it), level));
+        }
+        // truncate the duplicate case where 1 cell connect to > 1 neighbor cell.
+        List<Long> approxCells = new ArrayList<>(cells);
+        // clear cells, put the first cell as start
+        cells.clear();
+        cells.add(approxCells.get(0));
+        Set<Long> closetNeighbors = new HashSet<>(h3.gridDisk(approxCells.get(0), 1));
+        List<Long> candidates = new ArrayList<>();
+        int it = 1;
+        while (it < approxCells.size()) {
+            // if it's one of the neighbors of the closet cell,
+            long curCell = approxCells.get(it);
+            if (closetNeighbors.contains(curCell)) {
+                // do 1 step backward check
+                candidates.add(curCell);
+                it++;
+            } else {
+                // the curCell is not the neighbor of closest cell. means check for candidates ended.
+                long pickedCandidate = 0;
+                for (Long candidate : candidates) {
+                    List<Long> candidateNeighbors = h3.gridDisk(candidate, 1);
+                    if (candidateNeighbors.contains(curCell)){
+                        // find the cell that connect to both cur and closest, add into final list
+                        pickedCandidate = candidate;
+                        // if the candidate connect to both cur and next cell, means it's better to pick it
+                        if (it + 1 < approxCells.size() && candidateNeighbors.contains(approxCells.get(it + 1))) {
+                            break;
+                        }
+                    }
+                }
+                if (pickedCandidate != 0) {
+                    cells.add(pickedCandidate);
+                    candidates.clear();
+                    closetNeighbors = new HashSet<>(h3.gridDisk(pickedCandidate, 1));
+                } else if (!safe) {
+                    // if not need to guarantee safe, randomly pick 1 candidate
+                    cells.add(candidates.get(0));
+                    cells.add(curCell);
+                    closetNeighbors = new HashSet<>(h3.gridDisk(curCell, 1));
+                    candidates.clear();
+                    // if not raise error, make sure it always rotate
+                    it++;
+                } else {
+                    // our estimation shouldn't generate two adjacent cells in list that are not neighbors.
+                    // because we split the list by the min cell edge length / 3, and the least possible distance between the edges of 2 hexagon
+                    // with 1 hexagon in between equals to min cell edge length. We'll throw error here if the edge case found and use it for corner case study.
+                    // no matter what, move the iteration
+                    throw new H3UtilException(
+                            String.format(
+                                    "fail to approximate path between cell %d to %d, generated gap cell %d",
+                                    coordinateToCell(sc, level),
+                                    coordinateToCell(ec, level),
+                                    curCell
+                            )
+                    );
+                }
+            }
+        }
+        if (!candidates.isEmpty()) {
+            cells.add(candidates.get(0));
+        }
+        return new ArrayList<>(cells);
+    }
+
+    public static List<Long> lineStringToCells(LineString line, int level, boolean fullCover) {
+        try {
+            Coordinate[] coordinates = line.getCoordinates();
+            Set<Long> cells = new LinkedHashSet<>();
+            // for each segment, generate coverage separately
+            for (int pairE = 1; pairE < coordinates.length; pairE++) {
+                Coordinate cs = coordinates[pairE - 1];
+                Coordinate ce = coordinates[pairE];
+                long cellS = coordinateToCell(cs, level);
+                long cellE = coordinateToCell(ce, level);
+                List<Long> pathCells;
+                try {
+                    try {
+                        pathCells = h3.gridPathCells(cellS, cellE);
+                    } catch (H3Exception e) {
+                        pathCells = approxPathCells(cs, ce, level, true);
+                    }
+                    if (pathCells.size() <= 2 || !fullCover) {
+                        cells.addAll(pathCells);
+                    } else {
+                        // the shortest path from cs to ce not guarantee cover the line, for the missed part, we generate neighbors for the cells to cover.
+                        // We exclude the cells that only adjacent to 1 cell in the path to remove some redundancy, but this won't remove all redundancy.
+                        Set<Long> prevNeighbors = new HashSet<>(h3.gridDisk(pathCells.get(0), 1));
+                        for (int it = 1; it < pathCells.size(); it++) {
+                            Set<Long> neighbors = new HashSet<>(h3.gridDisk(pathCells.get(it), 1));
+                            prevNeighbors.retainAll(neighbors);
+                            cells.addAll(prevNeighbors);
+                            prevNeighbors = neighbors;
+                        }
+                    }
+                } catch (H3UtilException e) {
+                    if (fullCover) {
+                        cells.addAll(
+                                polygonToCells((Polygon) (new GeometryFactory().createLineString(new Coordinate[]{cs, ce}).getEnvelope()),
+                                        level,
+                                        true
+                                )
+                        );
+                    } else {
+                        // if not full cover, we'll throw error, cause for getting the shortest path, we suppose should have no error
+                        throw e;
+                    }
+                }
+            }
+            return new ArrayList<>(cells);
+        } catch (Exception e) {
+            throw new H3UtilException(
+                    String.format("fail to cover the line %s with error %s", GeomUtils.getWKT(line), e.getMessage()),
+                    e
+            );
+        }
+    }
+}
diff --git a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
index 5794b14d9..a6e355e1d 100644
--- a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
@@ -14,6 +14,7 @@
 package org.apache.sedona.common;
 
 import com.google.common.geometry.S2CellId;
+import org.apache.sedona.common.utils.H3Utils;
 import com.google.common.math.DoubleMath;
 import org.apache.sedona.common.sphere.Haversine;
 import org.apache.sedona.common.sphere.Spheroid;
@@ -28,9 +29,7 @@ import org.locationtech.jts.io.WKTWriter;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.operation.TransformException;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static org.junit.Assert.*;
@@ -86,7 +85,7 @@ public class FunctionsTest {
         actual = Constructors.geomFromEWKT(expectedResult);
         assertEquals(geometry, actual);
         assertEquals(expectedResult, actualResult);
-        
+
         geometry = geometryFactory.createPoint(new CoordinateXYM(1.0, 2.0, 3.0));
         actualResult = Functions.asEWKT(geometry);
         expectedResult = "SRID=4236;POINT M(1 2 3)";
@@ -117,14 +116,14 @@ public class FunctionsTest {
         actual = Constructors.geomFromEWKT(expectedResult);
         assertEquals(geometry, actual);
         assertEquals(expectedResult, actualResult);
-        
+
         geometry = GEOMETRY_FACTORY.createPoint(new CoordinateXYM(1.0, 2.0, 3.0));
         actualResult = Functions.asWKT(geometry);
         expectedResult = "POINT M(1 2 3)";
         actual = Constructors.geomFromEWKT(expectedResult);
         assertEquals(geometry, actual);
         assertEquals(expectedResult, actualResult);
-        
+
         geometry = GEOMETRY_FACTORY.createPoint(new CoordinateXYZM(1.0, 2.0, 3.0, 4.0));
         actualResult = Functions.asWKT(geometry);
         expectedResult = "POINT ZM(1 2 3 4)";
@@ -145,7 +144,7 @@ public class FunctionsTest {
         expected = Constructors.geomFromWKB(actualResult);
         assertEquals(expected, geometry);
     }
-    
+
     @Test
     public void splitLineStringByMultipoint() {
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0));
@@ -160,8 +159,8 @@ public class FunctionsTest {
     @Test
     public void splitMultiLineStringByMultiPoint() {
         LineString[] lineStrings = new LineString[]{
-            GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0)),
-            GEOMETRY_FACTORY.createLineString(coordArray(3.0, 3.0, 4.5, 4.5, 5.0, 5.0))
+                GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0)),
+                GEOMETRY_FACTORY.createLineString(coordArray(3.0, 3.0, 4.5, 4.5, 5.0, 5.0))
         };
         MultiLineString multiLineString = GEOMETRY_FACTORY.createMultiLineString(lineStrings);
         MultiPoint multiPoint = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray(0.5, 0.5, 1.0, 1.0, 3.5, 3.5, 4.0, 4.0));
@@ -242,8 +241,8 @@ public class FunctionsTest {
     @Test
     public void splitOverlappingMultiPolygonByLineString() {
         Polygon[] polygons = new Polygon[]{
-            GEOMETRY_FACTORY.createPolygon(coordArray(1.0, 1.0, 5.0, 1.0, 5.0, 5.0, 1.0, 5.0, 1.0, 1.0)),
-            GEOMETRY_FACTORY.createPolygon(coordArray(2.0, 1.0, 6.0, 1.0, 6.0, 5.0, 2.0, 5.0, 2.0, 1.0))
+                GEOMETRY_FACTORY.createPolygon(coordArray(1.0, 1.0, 5.0, 1.0, 5.0, 5.0, 1.0, 5.0, 1.0, 1.0)),
+                GEOMETRY_FACTORY.createPolygon(coordArray(2.0, 1.0, 6.0, 1.0, 6.0, 5.0, 2.0, 5.0, 2.0, 1.0))
         };
         MultiPolygon multiPolygon = GEOMETRY_FACTORY.createMultiPolygon(polygons);
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(3.0, 0.0, 3.0, 6.0));
@@ -291,7 +290,7 @@ public class FunctionsTest {
     public void splitPolygonWithHoleByLineStringThroughHole() {
         LinearRing shell = GEOMETRY_FACTORY.createLinearRing(coordArray(0.0, 0.0, 4.0, 0.0, 4.0, 4.0, 0.0, 4.0, 0.0, 0.0));
         LinearRing[] holes = new LinearRing[]{
-            GEOMETRY_FACTORY.createLinearRing(coordArray(1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0))
+                GEOMETRY_FACTORY.createLinearRing(coordArray(1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0))
         };
         Polygon polygon = GEOMETRY_FACTORY.createPolygon(shell, holes);
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(1.5, -1.0, 1.5, 5.0));
@@ -306,7 +305,7 @@ public class FunctionsTest {
     public void splitPolygonWithHoleByLineStringNotThroughHole() {
         LinearRing shell = GEOMETRY_FACTORY.createLinearRing(coordArray(0.0, 0.0, 4.0, 0.0, 4.0, 4.0, 0.0, 4.0, 0.0, 0.0));
         LinearRing[] holes = new LinearRing[]{
-            GEOMETRY_FACTORY.createLinearRing(coordArray(1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0))
+                GEOMETRY_FACTORY.createLinearRing(coordArray(1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0))
         };
         Polygon polygon = GEOMETRY_FACTORY.createPolygon(shell, holes);
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(3.0, -1.0, 3.0, 5.0));
@@ -320,8 +319,8 @@ public class FunctionsTest {
     @Test
     public void splitHomogeneousLinealGeometryCollectionByMultiPoint() {
         LineString[] lineStrings = new LineString[]{
-            GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0)),
-            GEOMETRY_FACTORY.createLineString(coordArray(3.0, 3.0, 4.5, 4.5, 5.0, 5.0))
+                GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5, 2.0, 2.0)),
+                GEOMETRY_FACTORY.createLineString(coordArray(3.0, 3.0, 4.5, 4.5, 5.0, 5.0))
         };
         GeometryCollection geometryCollection = GEOMETRY_FACTORY.createGeometryCollection(lineStrings);
         MultiPoint multiPoint = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray(0.5, 0.5, 1.0, 1.0, 3.5, 3.5, 4.0, 4.0));
@@ -335,8 +334,8 @@ public class FunctionsTest {
     @Test
     public void splitHeterogeneousGeometryCollection() {
         Geometry[] geometry = new Geometry[]{
-            GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5)),
-            GEOMETRY_FACTORY.createPolygon(coordArray(0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0))
+                GEOMETRY_FACTORY.createLineString(coordArray(0.0, 0.0, 1.5, 1.5)),
+                GEOMETRY_FACTORY.createPolygon(coordArray(0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0))
         };
         GeometryCollection geometryCollection = GEOMETRY_FACTORY.createGeometryCollection(geometry);
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(0.5, 0.0, 0.5, 5.0));
@@ -445,7 +444,7 @@ public class FunctionsTest {
                 new LinearRing[] {
                         GEOMETRY_FACTORY.createLinearRing(coordArray(0.2, 0.2, 0.5, 0.2, 0.6, 0.7, 0.2, 0.6, 0.2, 0.2))
                 }
-                );
+        );
         // polygon inside the hole, shouldn't intersect with the polygon
         Polygon polygonInHole = GEOMETRY_FACTORY.createPolygon(coordArray(0.3, 0.3, 0.4, 0.3, 0.3, 0.4, 0.3, 0.3));
         // mbr of the polygon that cover all
@@ -574,6 +573,113 @@ public class FunctionsTest {
         assertEquals(expects, levels);
     }
 
+    /**
+     * Test H3CellIds: pass in all the types of geometry, test if the function cover
+     */
+    @Test
+    public void h3CellIDs() {
+        Geometry[] combinedGeoms = new Geometry[] {
+                GEOMETRY_FACTORY.createPoint(new Coordinate(0.1, 0.1)),
+                GEOMETRY_FACTORY.createPoint(new Coordinate(0.2, 0.1)),
+                GEOMETRY_FACTORY.createLineString(coordArray(0.1, 0.1, 0.2, 0.1, 0.3, 0.4, 0.5, 0.9)),
+                GEOMETRY_FACTORY.createLineString(coordArray(0.5, 0.1, 0.1, 0.5, 0.3, 0.1)),
+                GEOMETRY_FACTORY.createPolygon(coordArray(0.1, 0.1, 0.5, 0.1, 0.1, 0.6, 0.1, 0.1)),
+                GEOMETRY_FACTORY.createPolygon(coordArray(0.2, 0.1, 0.6, 0.3, 0.7, 0.6, 0.2, 0.5, 0.2, 0.1))
+        };
+        // The test geometries, cover all 7 geometry types targeted
+        Geometry[] targets = new Geometry[] {
+                GEOMETRY_FACTORY.createPoint(new Coordinate(1, 2)),
+                GEOMETRY_FACTORY.createPolygon(
+                        GEOMETRY_FACTORY.createLinearRing(coordArray(0.1, 0.1, 0.5, 0.1, 1.0, 0.3, 1.0, 1.0, 0.1, 1.0, 0.1, 0.1)),
+                        new LinearRing[] {
+                                GEOMETRY_FACTORY.createLinearRing(coordArray(0.2, 0.2, 0.5, 0.2, 0.6, 0.7, 0.2, 0.6, 0.2, 0.2))
+                        }
+                ),
+                GEOMETRY_FACTORY.createLineString(coordArray(0.2, 0.2, 0.3, 0.4, 0.4, 0.6)),
+                GEOMETRY_FACTORY.createGeometryCollection(
+                        new Geometry[] {
+                                GEOMETRY_FACTORY.createMultiPoint(new Point[] {(Point) combinedGeoms[0], (Point) combinedGeoms[1]}),
+                                GEOMETRY_FACTORY.createMultiLineString(new LineString[] {(LineString) combinedGeoms[2], (LineString) combinedGeoms[3]}),
+                                GEOMETRY_FACTORY.createMultiPolygon(new Polygon[] {(Polygon) combinedGeoms[4], (Polygon) combinedGeoms[5]})
+                        }
+                )
+        };
+        int resolution = 7;
+        // the expected results
+        Set<Long> expects = new HashSet<>();
+        expects.addAll(new HashSet<>(Collections.singletonList(H3Utils.coordinateToCell(targets[0].getCoordinate(), resolution))));
+        expects.addAll(new HashSet<>(H3Utils.polygonToCells((Polygon) targets[1], resolution, true)));
+        expects.addAll(new HashSet<>(H3Utils.lineStringToCells((LineString) targets[2], resolution, true)));
+        // for GeometryCollection, generate separately for the underlying geoms
+        expects.add(H3Utils.coordinateToCell(combinedGeoms[0].getCoordinate(), resolution));
+        expects.add(H3Utils.coordinateToCell(combinedGeoms[1].getCoordinate(), resolution));
+        expects.addAll(H3Utils.lineStringToCells((LineString) combinedGeoms[2], resolution, true));
+        expects.addAll(H3Utils.lineStringToCells((LineString) combinedGeoms[3], resolution, true));
+        expects.addAll(H3Utils.polygonToCells((Polygon) combinedGeoms[4], resolution, true));
+        expects.addAll(H3Utils.polygonToCells((Polygon) combinedGeoms[5], resolution, true));
+        // generate exact
+        Set<Long> exacts = new HashSet<>(Arrays.asList(Functions.h3CellIDs(GEOMETRY_FACTORY.createGeometryCollection(targets), resolution, true)));
+        assert exacts.equals(expects);
+    }
+
+    /**
+     * Test H3CellDistance
+     */
+    @Test
+    public void h3CellDistance() {
+        LineString pentagonLine = GEOMETRY_FACTORY.createLineString(coordArray(58.174758948493505, 10.427371502467615, 58.1388817207103, 10.469490838693966));
+        // normal line
+        LineString line = GEOMETRY_FACTORY.createLineString(coordArray(-4.414062499999996, 19.790494005157534,5.781250000000004, 13.734595619093557));
+        long pentagonDist = Functions.h3CellDistance(
+                H3Utils.coordinateToCell(pentagonLine.getCoordinateN(0), 11),
+                H3Utils.coordinateToCell(pentagonLine.getCoordinateN(1), 11)
+        );
+        long lineDist = Functions.h3CellDistance(
+                H3Utils.coordinateToCell(line.getCoordinateN(0), 10),
+                H3Utils.coordinateToCell(line.getCoordinateN(1), 10)
+        );
+        assertEquals(
+                H3Utils.approxPathCells(
+                        pentagonLine.getCoordinateN(0),
+                        pentagonLine.getCoordinateN(1),
+                        11,
+                        true
+                ).size() - 1,
+                pentagonDist
+        );
+
+        assertEquals(
+                H3Utils.h3.gridDistance(
+                        H3Utils.coordinateToCell(line.getCoordinateN(0), 10),
+                        H3Utils.coordinateToCell(line.getCoordinateN(1), 10)
+                ),
+                lineDist
+        );
+    }
+
+    /**
+     * Test h3kRing
+     */
+    @Test
+    public void h3KRing() {
+        Point[] points = new Point[] {
+                // pentagon
+                GEOMETRY_FACTORY.createPoint(new Coordinate(10.53619907546767, 64.70000012793487)),
+                // 7th neighbor of pentagon
+                GEOMETRY_FACTORY.createPoint(new Coordinate(10.536630883471666, 64.69944253201858)),
+                // normal point
+                GEOMETRY_FACTORY.createPoint(new Coordinate(-166.093005914,61.61964122848931)),
+        };
+        for (Point point : points) {
+            long cell = H3Utils.coordinateToCell(point.getCoordinate(), 12);
+            Set<Long> allNeighbors = new HashSet<>(Arrays.asList(Functions.h3KRing(cell, 10, false)));
+            Set<Long> kthNeighbors = new HashSet<>(Arrays.asList(Functions.h3KRing(cell, 10, true)));
+            assert allNeighbors.containsAll(kthNeighbors);
+            kthNeighbors.addAll(Arrays.asList(Functions.h3KRing(cell, 9, false)));
+            assert allNeighbors.equals(kthNeighbors);
+        }
+    }
+
     @Test
     public void geometricMedian() throws Exception {
         MultiPoint multiPoint = GEOMETRY_FACTORY.createMultiPointFromCoords(
@@ -945,7 +1051,7 @@ public class FunctionsTest {
         LineString actualLinestring = (LineString) Functions.makeLine(point1, point2);
         LineString expectedLineString = GEOMETRY_FACTORY.createLineString(coordArray3d( 1, 1, 1, 2, 2, 2));
         assertEquals(wktWriter3D.write(actualLinestring), wktWriter3D.write(expectedLineString));
-        
+
         MultiPoint multiPoint1 = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray3d(0.5, 0.5, 1, 1, 1, 1));
         MultiPoint multiPoint2 = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray3d(0.5, 0.5, 2, 2, 2, 2));
         actualLinestring = (LineString) Functions.makeLine(multiPoint1, multiPoint2);
@@ -996,7 +1102,7 @@ public class FunctionsTest {
     public void nRingsPolygonWithHoles() throws Exception {
         LinearRing shell = GEOMETRY_FACTORY.createLinearRing(coordArray(1, 0, 1, 6, 6, 6, 6, 0, 1, 0));
         LinearRing[] holes = new LinearRing[] {GEOMETRY_FACTORY.createLinearRing(coordArray(2, 1, 2, 2, 3, 2, 3, 1, 2, 1)),
-                                                GEOMETRY_FACTORY.createLinearRing(coordArray(4, 1, 4, 2, 5, 2, 5, 1, 4, 1))};
+                GEOMETRY_FACTORY.createLinearRing(coordArray(4, 1, 4, 2, 5, 2, 5, 1, 4, 1))};
         Polygon polygonWithHoles = GEOMETRY_FACTORY.createPolygon(shell, holes);
         Integer expected = 3;
         Integer actual = Functions.nRings(polygonWithHoles);
@@ -1013,7 +1119,7 @@ public class FunctionsTest {
     @Test
     public void nRingsMultiPolygonOnlyExternal() throws Exception {
         MultiPolygon multiPolygon = GEOMETRY_FACTORY.createMultiPolygon(new Polygon[] {GEOMETRY_FACTORY.createPolygon(coordArray(1, 0, 1, 1, 2, 1, 2, 0, 1, 0)),
-                                                                                        GEOMETRY_FACTORY.createPolygon(coordArray(5, 0, 5, 1, 7, 1, 7, 0, 5, 0))});
+                GEOMETRY_FACTORY.createPolygon(coordArray(5, 0, 5, 1, 7, 1, 7, 0, 5, 0))});
         Integer expected = 2;
         Integer actual = Functions.nRings(multiPolygon);
         assertEquals(expected, actual);
@@ -1396,7 +1502,7 @@ public class FunctionsTest {
         assertEquals(expected, actual);
     }
 
-   @Test
+    @Test
     public void affine3DGeom2D() {
         LineString lineString = GEOMETRY_FACTORY.createLineString(coordArray(1, 0, 1, 1, 1, 2));
         String expected = GEOMETRY_FACTORY.createLineString(coordArray(4, 5, 5, 7, 6, 9)).toText();
@@ -1469,7 +1575,7 @@ public class FunctionsTest {
         String expected1 = "POINT";
         String actual1 = Functions.geometryTypeWithMeasured(GEOMETRY_FACTORY.createPoint(new Coordinate(10, 5)));
         assertEquals(expected1, actual1);
-        
+
         // Create a point with measure value
         CoordinateXYM coords = new CoordinateXYM(2, 3, 4);
         Point measuredPoint = GEOMETRY_FACTORY.createPoint(coords);
@@ -1497,7 +1603,7 @@ public class FunctionsTest {
         String expected1 = "POINT";
         String actual1 = Functions.geometryTypeWithMeasured(GEOMETRY_FACTORY.createPoint(new Coordinate(10, 5, 1)));
         assertEquals(expected1, actual1);
-        
+
         // Create a point with measure value
         CoordinateXYZM coordsPoint = new CoordinateXYZM(2, 3, 4, 0);
         Point measuredPoint = GEOMETRY_FACTORY.createPoint(coordsPoint);
@@ -1525,7 +1631,7 @@ public class FunctionsTest {
         String expected1 = "GEOMETRYCOLLECTION";
         String actual1 = Functions.geometryTypeWithMeasured(GEOMETRY_FACTORY.createGeometryCollection(new Geometry[] {GEOMETRY_FACTORY.createPoint(new Coordinate(10, 5))}));
         assertEquals(expected1, actual1);
-        
+
         // Create a geometrycollection with measure value
         CoordinateXYM coords = new CoordinateXYM(2, 3, 4);
         Point measuredPoint = GEOMETRY_FACTORY.createPoint(coords);
@@ -1610,7 +1716,7 @@ public class FunctionsTest {
         String expected = "ST_ClosestPoint doesn't support empty geometry object.";
         Exception e1 = assertThrows(IllegalArgumentException.class, () -> Functions.closestPoint(point, emptyLineString));
         assertEquals(expected, e1.getMessage());
-        
+
         // Both objects are empty
         Polygon emptyPolygon = GEOMETRY_FACTORY.createPolygon();
         Exception e2 = assertThrows(IllegalArgumentException.class, () -> Functions.closestPoint(emptyPolygon, emptyLineString));
@@ -1728,7 +1834,7 @@ public class FunctionsTest {
 
 
     }
-    
+
     @Test
     public void voronoiPolygons() {
         MultiPoint multiPoint = GEOMETRY_FACTORY.createMultiPointFromCoords(coordArray(0, 0, 2, 2));
diff --git a/common/src/test/java/org/apache/sedona/common/H3UtilTest.java b/common/src/test/java/org/apache/sedona/common/H3UtilTest.java
new file mode 100644
index 000000000..00e7622db
--- /dev/null
+++ b/common/src/test/java/org/apache/sedona/common/H3UtilTest.java
@@ -0,0 +1,242 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sedona.common;
+
+import com.uber.h3core.exceptions.H3Exception;
+import org.apache.sedona.common.utils.H3Utils;
+import org.junit.Test;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.LinearRing;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.Polygon;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertThrows;
+
+public class H3UtilTest
+{
+    public static final GeometryFactory GEOMETRY_FACTORY = new GeometryFactory();
+
+    private Coordinate[] coordArray(double... coordValues) {
+        Coordinate[] coords = new Coordinate[(int) (coordValues.length / 2)];
+        for (int i = 0; i < coordValues.length; i += 2) {
+            coords[(int) (i / 2)] = new Coordinate(coordValues[i], coordValues[i + 1]);
+        }
+        return coords;
+    }
+
+    public static Polygon[] cellsToJTSPolygons(List<Long> cells) {
+        return H3Utils.h3.cellsToMultiPolygon(cells, true).stream().map(
+                shellHoles -> {
+                    List<LinearRing> rings = shellHoles.stream().map(
+                            shell -> GEOMETRY_FACTORY.createLinearRing(shell.stream().map(latLng -> new Coordinate(latLng.lng, latLng.lat)).toArray(Coordinate[]::new))
+                    ).collect(Collectors.toList());
+                    LinearRing shell = rings.remove(0);
+                    if (rings.isEmpty()) {
+                        return GEOMETRY_FACTORY.createPolygon(shell);
+                    } else {
+                        return GEOMETRY_FACTORY.createPolygon(shell, rings.toArray(new LinearRing[0]));
+                    }
+                }
+        ).toArray(Polygon[]::new);
+    }
+
+    @Test
+    public void pointToCell() {
+        Point point = GEOMETRY_FACTORY.createPoint(
+                new Coordinate(0.0, 1.0)
+        );
+        long cellId = H3Utils.coordinateToCell(point.getCoordinate(), 13);
+        // the reversed polygon from cell should be able to cover point
+        assert cellsToJTSPolygons(Collections.singletonList(cellId))[0].contains(point);
+    }
+
+    @Test
+    public void polygonToCells() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON((-122.5062527079981 37.77488349032218,-122.5007595439356 37.732537587382446,-122.48839992479498 37.67223433509411,-122.3963894267481 37.69505755123785,-122.39501613573248 37.788450765773675,-122.46505397752935 37.79984535251623,-122.5062527079981 37.77488349032218))");
+        List<Long> cells = H3Utils.polygonToCells(target, 7, true);
+        // the cells of mbr must include all the cells' cells
+        Polygon mbr = (Polygon) target.getEnvelope();
+        List<Long> cellsMBR = H3Utils.polygonToCells(mbr, 7, true);
+        assert new HashSet<>(cellsMBR).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+    }
+
+    @Test
+    public void polygonToCellsNoMatch() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON ((-122.3852447 47.5606571, -122.385248 47.5605286, -122.385326 47.5605296, -122.3853281 47.5604473, -122.3852624 47.5604465, -122.3852646 47.5603628, -122.3853411 47.5603637, -122.3853543 47.5598464, -122.3846514 47.5598382, -122.3846307 47.5606499, -122.3852447 47.5606571))");
+        Point centroid = target.getCentroid();
+        long centroidCell = H3Utils.coordinateToCell(centroid.getCoordinate(), 8);
+        List<Long> cells = H3Utils.polygonToCells(target, 8, false);
+        assert cells.size() == 1 && cells.get(0) == centroidCell;
+    }
+
+    @Test
+    public void polygonToCellsNoMatchFullCover() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON ((-122.3852447 47.5606571, -122.385248 47.5605286, -122.385326 47.5605296, -122.3853281 47.5604473, -122.3852624 47.5604465, -122.3852646 47.5603628, -122.3853411 47.5603637, -122.3853543 47.5598464, -122.3846514 47.5598382, -122.3846307 47.5606499, -122.3852447 47.5606571))");
+        List<Long> cells = H3Utils.polygonToCells(target, 7, true);
+        // the cells of mbr must include all the cells' cells
+        Polygon mbr = (Polygon) target.getEnvelope();
+        List<Long> cellsMBR = H3Utils.polygonToCells(mbr, 7, true);
+        assert new HashSet<>(cellsMBR).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+    }
+
+    @Test
+    public void polygonToCellsNoFullCover() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON((-122.5062527079981 37.77488349032218,-122.5007595439356 37.732537587382446,-122.48839992479498 37.67223433509411,-122.3963894267481 37.69505755123785,-122.39501613573248 37.788450765773675,-122.46505397752935 37.79984535251623,-122.5062527079981 37.77488349032218))");
+        List<Long> cells = H3Utils.polygonToCells(target, 7, false);
+        // the cells of fullCover should include all the cells non-full cover
+        List<Long> cellsFullCover = H3Utils.polygonToCells(target, 7, true);
+        assert new HashSet<>(cellsFullCover).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert !cellPolygon.contains(target);
+        assert cellPolygon.intersects(target);
+    }
+
+    @Test
+    public void polygonOnPentagonToCells() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON((10.47311531687734 64.74411329535432,10.427796713361715 64.67488499523719,10.543153158674215 64.64902571378299,10.674989096174215 64.68017135781035,10.595338217267965 64.76636949080041,10.47311531687734 64.74411329535432))");
+        List<Long> cells = H3Utils.polygonToCells(target, 6, true);
+        // the cells of mbr must include all the cells' cells
+        Polygon mbr = (Polygon) target.getEnvelope();
+        List<Long> cellsMBR = H3Utils.polygonToCells(mbr, 6, true);
+        assert new HashSet<>(cellsMBR).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+    }
+
+    @Test
+    public void polygonWithHolesToCells() throws ParseException {
+        Polygon target = (Polygon) new WKTReader().read("POLYGON((-122.49150256862254 37.76006117790207,-122.46506671657176 37.78394270449753,-122.41906146754832 37.77715896429647,-122.3905656789741 37.74187348046013,-122.42524127711863 37.71254658823643,-122.47811298122019 37.72666839340869,-122.49150256862254 37.76006117790207), (-122.44927386989207 37.73752948850401,-122.42798785914988 37.74920338883217,-122.42730121364207 37.76196112716144,-122.46335010280222 37.76250396084337,-122.4 [...]
+        List<Long> cells = H3Utils.polygonToCells(target, 9, true);
+        // the cells of mbr must include all the cells' cells
+        Polygon mbr = (Polygon) target.getEnvelope();
+        List<Long> cellsMBR = H3Utils.polygonToCells(mbr, 9, true);
+        assert new HashSet<>(cellsMBR).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for connected cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+        // catch exception
+        Exception exception = assertThrows(RuntimeException.class, () -> {
+            H3Utils.polygonToCells(
+                    (Polygon) new WKTReader().read("POLYGON ((75 29, 77 29, 75 29))"),
+                    7,
+                    true
+            );
+        });
+        assert exception.toString().contains("POLYGON ((75 29, 77 29, 75 29))");
+    }
+
+    @Test
+    public void approxPathCells()  {
+        LineString target = GEOMETRY_FACTORY.createLineString(coordArray(-122.532, 37.771, -122.589, 37.743));
+        List<Long> cells = H3Utils.lineStringToCells(target, 8, false);
+        List<Long> approxCells = H3Utils.approxPathCells(target.getCoordinateN(0), target.getCoordinateN(1), 8, true);
+        // after truncation, removed redundant cells
+        assert approxCells.size() == cells.size();
+    }
+
+    @Test
+    public void approxPathCellsPentagon()  {
+        LineString target = GEOMETRY_FACTORY.createLineString(coordArray(58.174758948493505, 10.427371502467615, 58.1388817207103, 10.469490838693966));
+        // assert use h3 native function will throw error
+        assertThrows(H3Exception.class, () -> {
+            H3Utils.h3.gridPathCells(
+                    H3Utils.coordinateToCell(target.getCoordinateN(0), 10),
+                    H3Utils.coordinateToCell(target.getCoordinateN(1), 10)
+            );
+        });
+        List<Long> cells = H3Utils.approxPathCells(
+                target.getCoordinateN(0),
+                target.getCoordinateN(1),
+                10,
+                true
+        );
+        Long pentagonCell = cells.stream().filter(H3Utils.h3::isPentagon).collect(Collectors.toList()).get(0);
+        Set<Long> h3Cells = new HashSet<>(
+                H3Utils.h3.gridPathCells(
+                        H3Utils.coordinateToCell(target.getCoordinateN(0), 10),
+                        pentagonCell
+                )
+        );
+        h3Cells.addAll(H3Utils.h3.gridPathCells(
+                pentagonCell,
+                H3Utils.coordinateToCell(target.getCoordinateN(1), 10)
+        ));
+        assert cells.size() == h3Cells.size();
+    }
+
+    @Test
+    public void lineStringToCells()  {
+        LineString target = GEOMETRY_FACTORY.createLineString(coordArray(-122.589, 37.743, -122.532, 37.771, -122.423, 37.742, -122.323, 37.842));
+        List<Long> cells = H3Utils.lineStringToCells(target, 7, true);
+        // the cells of mbr must include all the cells' cells
+        Polygon mbr = (Polygon) target.getEnvelope();
+        List<Long> cellsMBR = H3Utils.polygonToCells(mbr, 7, true);
+        assert new HashSet<>(cellsMBR).containsAll(cells);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+    }
+
+    @Test
+    public void lineStringCrossPentagonToCells()  {
+        // this line cross the pentagon
+        LineString target = GEOMETRY_FACTORY.createLineString(coordArray(10.466683443818056, 64.72575037391769,10.595772799286806, 64.66235272011512));
+        // first this case throw error when call native h3 functions
+        assertThrows(H3Exception.class, () -> H3Utils.h3.gridPathCells(
+                H3Utils.coordinateToCell(target.getCoordinateN(0), 6),
+                H3Utils.coordinateToCell(target.getCoordinateN(1), 6)
+        ));
+        List<Long> cells = H3Utils.lineStringToCells(target, 6, true);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for conjective cells
+        Polygon cellPolygon = cellsToJTSPolygons(cells)[0];
+        // the reversed polygons from cells must all intersect with the polygon, this means the indexing geographically make sense
+        assert cellPolygon.contains(target);
+    }
+
+    @Test
+    public void lineStringCrossPentagonToCellsNonFullCover()  {
+        // this line cross the pentagon
+        LineString target = GEOMETRY_FACTORY.createLineString(coordArray(10.466683443818056, 64.72575037391769,10.595772799286806, 64.66235272011512));
+        List<Long> cellsFullCover = H3Utils.lineStringToCells(target, 6, true);
+        List<Long> cellsNonFullCover = H3Utils.lineStringToCells(target, 6, false);
+        // generate the reversed polygons from cells, the h3 generate 1 compacted polygon for adjacent cells
+        List<Long> approxCells = H3Utils.approxPathCells(target.getCoordinateN(0), target.getCoordinateN(1), 6, true);
+        assert approxCells.equals(cellsNonFullCover);
+        assert !approxCells.equals(cellsFullCover);
+    }
+}
\ No newline at end of file
diff --git a/docs/api/flink/Function.md b/docs/api/flink/Function.md
index 15a216943..f5d8b51b2 100644
--- a/docs/api/flink/Function.md
+++ b/docs/api/flink/Function.md
@@ -1211,6 +1211,127 @@ Output:
 ST_LINESTRING
 ```
 
+## ST_H3CellDistance
+
+Introduction: return result of h3 function [gridDistance(cel1, cell2)](https://h3geo.org/docs/api/traversal#griddistance).
+As described by H3 documentation
+> Finding the distance can fail because the two indexes are not comparable (different resolutions), too far apart, or are separated by pentagonal distortion. This is the same set of limitations as the local IJ coordinate space functions.
+
+In this case, Sedona use in-house implementation of estimation the shortest path and return the size as distance.
+
+Format: `ST_H3CellDistance(cell1: Long, cell2: Long)`
+
+Since: `v1.5.0`
+
+Example:
+```SQL
+select ST_H3CellDistance(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], ST_H3CellIDs(ST_GeomFromWKT('POINT(1.23 1.59)'), 8, true)[1])
+```
+
+Output:
+```
++----+----------------------+
+| op |               EXPR$0 |
++----+----------------------+
+| +I |                   78 |
++----+----------------------+
+```
+
+## ST_H3CellIDs
+
+Introduction: Cover the geometry by H3 cell IDs with the given resolution(level).
+To understand the cell statistics please refer to [H3 Doc](https://h3geo.org/docs/core-library/restable)
+H3 native fill functions doesn't guarantee full coverage on the shapes.
+
+### Cover Polygon
+When fullCover = false, for polygon sedona will use [polygonToCells](https://h3geo.org/docs/api/regions#polygontocells).
+This can't guarantee full coverage but will guarantee no false positive.
+
+When fullCover = true, sedona will add on extra traversal logic to guarantee full coverage on shapes.
+This will lead to redundancy but can guarantee full coverage.
+
+Choose the option according to your use case.
+
+### Cover LineString
+For the lineString, sedona will call gridPathCells(https://h3geo.org/docs/api/traversal#gridpathcells) per segment.
+From H3's documentation
+> This function may fail to find the line between two indexes, for example if they are very far apart. It may also fail when finding distances for indexes on opposite sides of a pentagon.
+
+When the `gridPathCells` function throw error, Sedona implemented in-house approximate implementation to generate the shortest path, which can cover the corner cases.
+
+Both functions can't guarantee full coverage. When the `fullCover = true`, we'll do extra cell traversal to guarantee full cover.
+In worst case, sedona will use MBR to guarantee the full coverage.
+
+If you seek to get the shortest path between cells, you can call this function with `fullCover = false`
+
+Format: `ST_H3CellIDs(geom: geometry, level: Int, fullCover: true)`
+
+Since: `v1.5.0`
+
+Example:
+```SQL
+SELECT ST_H3CellIDs(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'), 6, true)
+```
+
+Output:
+```
++----+--------------------------------+
+| op |                         EXPR$0 |
++----+--------------------------------+
+| +I | [605547539457900543, 605547... |
++----+--------------------------------+
+```
+
+## ST_H3KRing
+
+Introduction: return the result of H3 function [gridDisk(cell, k)](https://h3geo.org/docs/api/traversal#griddisk).
+
+K means `the distance of the origin index`, `gridDisk(cell, k)` return cells with distance `<=k` from the original cell.
+
+`exactRing : Boolean`, when set to `true`, sedona will remove the result of `gridDisk(cell, k-1)` from the original results,
+means only keep the cells with distance exactly `k` from the original cell
+
+Format: `ST_H3KRing(cell: Long, k: Int, exactRing: Boolean)`
+
+Since: `v1.5.0`
+
+Example:
+```SQL
+select ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 1, false), ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 1, true)
+```
+
+Output:
+```
++----+--------------------------------+--------------------------------+
+| op |                         EXPR$0 |                         EXPR$1 |
++----+--------------------------------+--------------------------------+
+| +I | [614552609325318143, 614552... | [614552597293957119, 614552... |
++----+--------------------------------+--------------------------------+
+```
+
+## ST_H3ToGeom
+
+Introduction: return the result of H3 function [cellsToMultiPolygon(cells)](https://h3geo.org/docs/api/regions#cellstolinkedmultipolygon--cellstomultipolygon).
+
+Reverse the uber h3 cells to MultiPolygon object composed by the geometry hexagons.
+
+Format: `ST_H3ToGeom(cells: Array[Long])`
+
+Since: `v1.5.0`
+
+Example:
+```SQL
+SELECT ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, true))
+```
+
+Output:
+```
+|st_h3togeom(st_h3cellids(st_geomfromwkt(POINT(1 2), 0), 8, true))                                                                                                                                                                                                                              |
++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|MULTIPOLYGON (((1.0057629565404935 1.9984665139177658, 1.0037116327309032 2.001832524914011, 0.9997277993570498 2.0011632704656668, 0.9977951427833285 1.99712822839324, 0.9998461908217768 1.9937621529331915, 1.0038301712104252 1.9944311839965554, 1.0057629565404935 1.9984665139177658)))|
++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+```
+
 ## ST_HausdorffDistance
 
 Introduction: Returns a discretized (and hence approximate) [Hausdorff distance](https://en.wikipedia.org/wiki/Hausdorff_distance) between the given 2 geometries. 
diff --git a/docs/api/sql/Function.md b/docs/api/sql/Function.md
index cc3634ef7..859bc554c 100644
--- a/docs/api/sql/Function.md
+++ b/docs/api/sql/Function.md
@@ -1220,6 +1220,128 @@ Output:
 ST_LINESTRING
 ```
 
+## ST_H3CellDistance
+
+Introduction: return result of h3 function [gridDistance(cel1, cell2)](https://h3geo.org/docs/api/traversal#griddistance).
+As described by H3 documentation
+> Finding the distance can fail because the two indexes are not comparable (different resolutions), too far apart, or are separated by pentagonal distortion. This is the same set of limitations as the local IJ coordinate space functions.
+
+In this case, Sedona use in-house implementation of estimation the shortest path and return the size as distance.
+
+Format: `ST_H3CellDistance(cell1: Long, cell2: Long)`
+
+Since: `v1.5.0`
+
+Spark SQL example:
+```SQL
+select ST_H3CellDistance(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], ST_H3CellIDs(ST_GeomFromWKT('POINT(1.23 1.59)'), 8, true)[0])
+```
+
+Output:
+```
++-----------------------------------------------------------------------------------------------------------------------------------------+
+|st_h3celldistance(st_h3cellids(st_geomfromwkt(POINT(1 2), 0), 8, true)[0], st_h3cellids(st_geomfromwkt(POINT(1.23 1.59), 0), 8, true)[0])|
++-----------------------------------------------------------------------------------------------------------------------------------------+
+|                                                                                                                                       78|
++-----------------------------------------------------------------------------------------------------------------------------------------+
+```
+
+## ST_H3CellIDs
+
+Introduction: Cover the geometry by H3 cell IDs with the given resolution(level).
+To understand the cell statistics please refer to [H3 Doc](https://h3geo.org/docs/core-library/restable)
+H3 native fill functions doesn't guarantee full coverage on the shapes.
+
+### Cover Polygon
+When fullCover = false, for polygon sedona will use [polygonToCells](https://h3geo.org/docs/api/regions#polygontocells).
+This can't guarantee full coverage but will guarantee no false positive.
+
+When fullCover = true, sedona will add on extra traversal logic to guarantee full coverage on shapes.
+This will lead to redundancy but can guarantee full coverage.
+
+Choose the option according to your use case.
+
+### Cover LineString
+For the lineString, sedona will call gridPathCells(https://h3geo.org/docs/api/traversal#gridpathcells) per segment.
+From H3's documentation
+> This function may fail to find the line between two indexes, for example if they are very far apart. It may also fail when finding distances for indexes on opposite sides of a pentagon.
+
+When the `gridPathCells` function throw error, Sedona implemented in-house approximate implementation to generate the shortest path, which can cover the corner cases.
+
+Both functions can't guarantee full coverage. When the `fullCover = true`, we'll do extra cell traversal to guarantee full cover.
+In worst case, sedona will use MBR to guarantee the full coverage.
+
+If you seek to get the shortest path between cells, you can call this function with `fullCover = false`
+
+Format: `ST_H3CellIDs(geom: geometry, level: Int, fullCover: Boolean)`
+
+Since: `v1.5.0`
+
+Spark SQL example:
+```SQL
+SELECT ST_H3CellIDs(ST_GeomFromText('LINESTRING(1 3 4, 5 6 7)'), 6, true)
+```
+
+Output:
+```
++-------------------------------------------------------------+
+|st_h3cellids(st_geomfromtext(LINESTRING(1 3 4, 5 6 7), 0), 6)|
++-------------------------------------------------------------+
+|                                         [6055475394579005...|
++-------------------------------------------------------------+
+```
+
+## ST_H3KRing
+
+Introduction: return the result of H3 function [gridDisk(cell, k)](https://h3geo.org/docs/api/traversal#griddisk).
+
+K means `the distance of the origin index`, `gridDisk(cell, k)` return cells with distance `<=k` from the original cell.
+
+`exactRing : Boolean`, when set to `true`, sedona will remove the result of `gridDisk(cell, k-1)` from the original results,
+means only keep the cells with distance exactly `k` from the original cell
+
+Format: `ST_H3KRing(cell: Long, k: Int, exactRing: Boolean)`
+
+Since: `v1.5.0`
+
+Spark SQL example:
+```SQL
+SELECT ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, true) cells union select ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, false) cells
+```
+
+Output:
+```
++--------------------------------------------------------------------------------------------------------------------------------------------+
+|cells                                                                                                                                       |
++--------------------------------------------------------------------------------------------------------------------------------------------+
+|[614552597293957119, 614552609329512447, 614552609316929535, 614552609327415295, 614552609287569407, 614552597289762815]                    |
+|[614552609325318143, 614552597293957119, 614552609329512447, 614552609316929535, 614552609327415295, 614552609287569407, 614552597289762815]|
++--------------------------------------------------------------------------------------------------------------------------------------------+
+```
+
+## ST_H3ToGeom
+
+Introduction: return the result of H3 function [cellsToMultiPolygon(cells)](https://h3geo.org/docs/api/regions#cellstolinkedmultipolygon--cellstomultipolygon).
+
+Reverse the uber h3 cells to MultiPolygon object composed by the geometry hexagons.
+
+Format: `ST_H3ToGeom(cells: Array[Long])`
+
+Since: `v1.5.0`
+
+Spark SQL example:
+```SQL
+SELECT ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, true))
+```
+
+Output:
+```
+|st_h3togeom(st_h3cellids(st_geomfromwkt(POINT(1 2), 0), 8, true))                                                                                                                                                                                                                              |
++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|MULTIPOLYGON (((1.0057629565404935 1.9984665139177658, 1.0037116327309032 2.001832524914011, 0.9997277993570498 2.0011632704656668, 0.9977951427833285 1.99712822839324, 0.9998461908217768 1.9937621529331915, 1.0038301712104252 1.9944311839965554, 1.0057629565404935 1.9984665139177658)))|
++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+```
+
 ## ST_HausdorffDistance
 
 Introduction: Returns a discretized (and hence approximate) [Hausdorff distance](https://en.wikipedia.org/wiki/Hausdorff_distance) between the given 2 geometries.
diff --git a/flink/src/main/java/org/apache/sedona/flink/Catalog.java b/flink/src/main/java/org/apache/sedona/flink/Catalog.java
index 0ee73259c..06538d901 100644
--- a/flink/src/main/java/org/apache/sedona/flink/Catalog.java
+++ b/flink/src/main/java/org/apache/sedona/flink/Catalog.java
@@ -59,6 +59,10 @@ public class Catalog {
                 new Functions.ST_DistanceSphere(),
                 new Functions.ST_DistanceSpheroid(),
                 new Functions.ST_3DDistance(),
+                new Functions.ST_H3CellDistance(),
+                new Functions.ST_H3CellIDs(),
+                new Functions.ST_H3KRing(),
+                new Functions.ST_H3ToGeom(),
                 new Functions.ST_Dump(),
                 new Functions.ST_DumpPoints(),
                 new Functions.ST_EndPoint(),
diff --git a/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java b/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
index 7c34ecd61..701e7eeb3 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
@@ -21,6 +21,7 @@ import org.apache.sedona.common.FunctionsGeoTools;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.operation.buffer.BufferParameters;
 
+import java.util.Arrays;
 
 public class Functions {
     public static class GeometryType extends ScalarFunction {
@@ -50,7 +51,7 @@ public class Functions {
     public static class ST_Azimuth extends ScalarFunction {
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             return org.apache.sedona.common.Functions.azimuth(geom1, geom2);
@@ -68,7 +69,7 @@ public class Functions {
     public static class ST_Buffer extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
-                Object o, @DataTypeHint("Double") Double radius) {
+        Object o, @DataTypeHint("Double") Double radius) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.buffer(geom, radius);
         }
@@ -77,13 +78,13 @@ public class Functions {
     public static class ST_ClosestPoint extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g1,
-        @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
             Geometry geom1 = (Geometry) g1;
             Geometry geom2 = (Geometry) g2;
             return org.apache.sedona.common.Functions.closestPoint(geom1, geom2);
         }
     }
-    
+
     public static class ST_Centroid extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o) {
@@ -94,8 +95,8 @@ public class Functions {
 
     public static class ST_Collect extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
-        public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1, 
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2  ) {
+        public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2  ) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             Geometry[] geoms = new Geometry[]{geom1, geom2};
@@ -108,7 +109,7 @@ public class Functions {
             return org.apache.sedona.common.Functions.createMultiGeometry(geoms);
         }
     }
-    
+
     public static class ST_CollectionExtract extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o) {
@@ -118,7 +119,7 @@ public class Functions {
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Integer") Integer geoType) {
+                @DataTypeHint("Integer") Integer geoType) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.collectionExtract(geom, geoType);
         }
@@ -127,14 +128,14 @@ public class Functions {
     public static class ST_ConcaveHull extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double pctConvex) {
+                @DataTypeHint("Double") Double pctConvex) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.concaveHull(geom, pctConvex, false);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double pctConvex, @DataTypeHint("Boolean") Boolean allowHoles) {
+                @DataTypeHint("Double") Double pctConvex, @DataTypeHint("Boolean") Boolean allowHoles) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.concaveHull(geom, pctConvex, allowHoles);
         }
@@ -167,7 +168,7 @@ public class Functions {
     public static class ST_Difference extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             return org.apache.sedona.common.Functions.difference(geom1, geom2);
@@ -215,7 +216,7 @@ public class Functions {
     public static class ST_3DDistance extends ScalarFunction {
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             return org.apache.sedona.common.Functions.distance3d(geom1, geom2);
@@ -245,7 +246,7 @@ public class Functions {
             return org.apache.sedona.common.Functions.endPoint(geom1);
         }
     }
-    
+
     public static class ST_GeometryType extends ScalarFunction {
         @DataTypeHint("String")
         public String eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o) {
@@ -257,7 +258,7 @@ public class Functions {
     public static class ST_Intersection extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g1,
-        @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
             Geometry geom1 = (Geometry) g1;
             Geometry geom2 = (Geometry) g2;
             return org.apache.sedona.common.Functions.intersection(geom1, geom2);
@@ -283,7 +284,7 @@ public class Functions {
     public static class ST_LineInterpolatePoint extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double fraction) {
+                @DataTypeHint("Double") Double fraction) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.lineInterpolatePoint(geom, fraction);
         }
@@ -356,7 +357,7 @@ public class Functions {
     public static class ST_ReducePrecision extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Integer") Integer precisionScale) {
+                @DataTypeHint("Integer") Integer precisionScale) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.reducePrecision(geom, precisionScale);
         }
@@ -385,7 +386,7 @@ public class Functions {
             return org.apache.sedona.common.Functions.interiorRingN(geom, n);
         }
     }
-    
+
     public static class ST_PointN extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o, int n) {
@@ -605,7 +606,7 @@ public class Functions {
     public static class ST_AddPoint extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry linestring = (Geometry) o1;
             Geometry point = (Geometry) o2;
             return org.apache.sedona.common.Functions.addPoint(linestring, point);
@@ -613,8 +614,8 @@ public class Functions {
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2,
-                             int position) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2,
+                int position) {
             Geometry linestring = (Geometry) o1;
             Geometry point = (Geometry) o2;
             return org.apache.sedona.common.Functions.addPoint(linestring, point, position);
@@ -638,7 +639,7 @@ public class Functions {
     public static class ST_SetPoint extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1, int position,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry linestring = (Geometry) o1;
             Geometry point = (Geometry) o2;
             return org.apache.sedona.common.Functions.setPoint(linestring, position, point);
@@ -664,7 +665,7 @@ public class Functions {
     public static class ST_LineSubstring extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double startFraction, @DataTypeHint("Double") Double endFraction) {
+                @DataTypeHint("Double") Double startFraction, @DataTypeHint("Double") Double endFraction) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.lineSubString(geom, startFraction, endFraction);
         }
@@ -673,7 +674,7 @@ public class Functions {
     public static class ST_MakeLine extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             return org.apache.sedona.common.Functions.makeLine(geom1, geom2);
@@ -685,11 +686,11 @@ public class Functions {
             return org.apache.sedona.common.Functions.makeLine(geoms);
         }
     }
-    
+
     public static class ST_MakePolygon extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(inputGroup = InputGroup.ANY) Object o2) {
+                @DataTypeHint(inputGroup = InputGroup.ANY) Object o2) {
             Geometry outerLinestring = (Geometry) o1;
             Geometry[] interiorLinestrings = (Geometry[]) o2;
             return org.apache.sedona.common.Functions.makePolygon(outerLinestring, interiorLinestrings);
@@ -705,7 +706,7 @@ public class Functions {
     public static class ST_Polygon extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint("Integer") Integer srid) {
+                @DataTypeHint("Integer") Integer srid) {
             Geometry linestring = (Geometry) o1;
             return org.apache.sedona.common.Functions.makepolygonWithSRID(linestring, srid);
         }
@@ -714,7 +715,7 @@ public class Functions {
     public static class ST_MakeValid extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Boolean") Boolean keepCollapsed) {
+                @DataTypeHint("Boolean") Boolean keepCollapsed) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.makeValid(geom, keepCollapsed);
         }
@@ -729,7 +730,7 @@ public class Functions {
     public static class ST_MinimumBoundingCircle extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Integer") Integer quadrantSegments) {
+                @DataTypeHint("Integer") Integer quadrantSegments) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.minimumBoundingCircle(geom, quadrantSegments);
         }
@@ -768,7 +769,7 @@ public class Functions {
     public static class ST_Split extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry input = (Geometry) o1;
             Geometry blade = (Geometry) o2;
             return org.apache.sedona.common.Functions.split(input, blade);
@@ -778,16 +779,55 @@ public class Functions {
     public static class ST_S2CellIDs extends ScalarFunction {
         @DataTypeHint(value = "ARRAY<BIGINT>")
         public Long[] eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("INT") Integer level) {
+                @DataTypeHint("INT") Integer level) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.s2CellIDs(geom, level);
         }
     }
 
+    public static class ST_H3CellIDs extends ScalarFunction {
+        @DataTypeHint(value = "ARRAY<BIGINT>")
+        public Long[] eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
+                @DataTypeHint("INT") Integer level,
+                @DataTypeHint("Boolean") Boolean fullCover
+        ) {
+            Geometry geom = (Geometry) o;
+            return org.apache.sedona.common.Functions.h3CellIDs(geom, level, fullCover);
+        }
+    }
+
+    public static class ST_H3CellDistance extends ScalarFunction {
+        @DataTypeHint(value = "BIGINT")
+        public Long eval(@DataTypeHint("BIGINT") Long cell1,
+                @DataTypeHint("BIGINT") Long cell2
+        ) {
+            return org.apache.sedona.common.Functions.h3CellDistance(cell1, cell2);
+        }
+    }
+
+    public static class ST_H3KRing extends ScalarFunction {
+        @DataTypeHint(value = "ARRAY<BIGINT>")
+        public Long[] eval(@DataTypeHint("BIGINT") Long cell,
+                @DataTypeHint("INTEGER") Integer k,
+                @DataTypeHint("Boolean") Boolean exactRing
+        ) {
+            return org.apache.sedona.common.Functions.h3KRing(cell, k, exactRing);
+        }
+    }
+
+    public static class ST_H3ToGeom extends ScalarFunction {
+        @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
+        public Geometry eval(@DataTypeHint(value = "ARRAY<BIGINT>") Long[] cells
+        ) {
+            return org.apache.sedona.common.Functions.h3ToGeom(Arrays.stream(cells).mapToLong(Long::longValue).toArray());
+        }
+    }
+
+
     public static class ST_SimplifyPreserveTopology extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                               @DataTypeHint("Double") Double distanceTolerance) {
+                @DataTypeHint("Double") Double distanceTolerance) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.simplifyPreserveTopology(geom, distanceTolerance);
         }
@@ -796,7 +836,7 @@ public class Functions {
     public static class ST_Subdivide extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry[].class)
         public Geometry[] eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                               @DataTypeHint("INT") Integer maxVertices) {
+                @DataTypeHint("INT") Integer maxVertices) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.subDivide(geom, maxVertices);
         }
@@ -805,7 +845,7 @@ public class Functions {
     public static class ST_SymDifference extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o1,
-                             @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o2) {
             Geometry geom1 = (Geometry) o1;
             Geometry geom2 = (Geometry) o2;
             return org.apache.sedona.common.Functions.symDifference(geom1, geom2);
@@ -821,23 +861,23 @@ public class Functions {
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double tolerance) throws Exception {
+                @DataTypeHint("Double") Double tolerance) throws Exception {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.geometricMedian(geometry, tolerance);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double tolerance,
-                             int maxIter) throws Exception {
+                @DataTypeHint("Double") Double tolerance,
+                int maxIter) throws Exception {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.geometricMedian(geometry, tolerance, maxIter);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double tolerance,
-                             int maxIter, @DataTypeHint("Boolean") Boolean failIfNotConverged) throws Exception {
+                @DataTypeHint("Double") Double tolerance,
+                int maxIter, @DataTypeHint("Boolean") Boolean failIfNotConverged) throws Exception {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.geometricMedian(geometry, tolerance, maxIter, failIfNotConverged);
         }
@@ -846,7 +886,7 @@ public class Functions {
     public static class ST_FrechetDistance extends ScalarFunction {
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g1,
-        @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) {
             Geometry geom1 = (Geometry) g1;
             Geometry geom2 = (Geometry) g2;
             return org.apache.sedona.common.Functions.frechetDistance(geom1, geom2);
@@ -865,7 +905,7 @@ public class Functions {
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double zValue) {
+                @DataTypeHint("Double") Double zValue) {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.force3D(geometry, zValue);
         }
@@ -888,14 +928,14 @@ public class Functions {
     public static class ST_Translate extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double deltaX, @DataTypeHint("Double") Double deltaY) {
+                @DataTypeHint("Double") Double deltaX, @DataTypeHint("Double") Double deltaY) {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.translate(geometry, deltaX, deltaY);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double deltaX, @DataTypeHint("Double") Double deltaY, @DataTypeHint("Double") Double deltaZ) {
+                @DataTypeHint("Double") Double deltaX, @DataTypeHint("Double") Double deltaY, @DataTypeHint("Double") Double deltaZ) {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.translate(geometry, deltaX, deltaY, deltaZ);
         }
@@ -904,7 +944,7 @@ public class Functions {
     public static class ST_VoronoiPolygons extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double tolerance, @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object extend) {
+                @DataTypeHint("Double") Double tolerance, @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object extend) {
             Geometry geom= (Geometry) o;
             Geometry extendTo= (Geometry) extend;
             return FunctionsGeoTools.voronoiPolygons(geom, tolerance, extendTo);
@@ -912,7 +952,7 @@ public class Functions {
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o,
-                             @DataTypeHint("Double") Double tolerance) {
+                @DataTypeHint("Double") Double tolerance) {
             Geometry geom= (Geometry) o;
             return FunctionsGeoTools.voronoiPolygons(geom, tolerance, null);
         }
@@ -927,16 +967,16 @@ public class Functions {
     public static class ST_Affine extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = Geometry.class) Object o, @DataTypeHint("Double") Double a,
-                             @DataTypeHint("Double") Double b, @DataTypeHint("Double") Double c, @DataTypeHint("Double") Double d, @DataTypeHint("Double") Double e, @DataTypeHint("Double") Double f, @DataTypeHint("Double") Double g, @DataTypeHint("Double") Double h, @DataTypeHint("Double") Double i, @DataTypeHint("Double") Double xOff, @DataTypeHint("Double") Double yOff,
-                             @DataTypeHint("Double") Double zOff) {
+                @DataTypeHint("Double") Double b, @DataTypeHint("Double") Double c, @DataTypeHint("Double") Double d, @DataTypeHint("Double") Double e, @DataTypeHint("Double") Double f, @DataTypeHint("Double") Double g, @DataTypeHint("Double") Double h, @DataTypeHint("Double") Double i, @DataTypeHint("Double") Double xOff, @DataTypeHint("Double") Double yOff,
+                @DataTypeHint("Double") Double zOff) {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.affine(geometry, a, b, c, d, e, f, g, h, i, xOff, yOff, zOff);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object o, @DataTypeHint("Double") Double a,
-                             @DataTypeHint("Double") Double b,  @DataTypeHint("Double") Double d, @DataTypeHint("Double") Double e,
-                             @DataTypeHint("Double") Double xOff, @DataTypeHint("Double") Double yOff) {
+                @DataTypeHint("Double") Double b,  @DataTypeHint("Double") Double d, @DataTypeHint("Double") Double e,
+                @DataTypeHint("Double") Double xOff, @DataTypeHint("Double") Double yOff) {
             Geometry geometry = (Geometry) o;
             return org.apache.sedona.common.Functions.affine(geometry, a, b, d, e, xOff, yOff);
         }
@@ -954,8 +994,8 @@ public class Functions {
     public static class ST_HausdorffDistance extends ScalarFunction {
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2,
-                           @DataTypeHint("Double") Double densityFrac) throws Exception {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2,
+                @DataTypeHint("Double") Double densityFrac) throws Exception {
             Geometry geom1 = (Geometry) g1;
             Geometry geom2 = (Geometry) g2;
             return org.apache.sedona.common.Functions.hausdorffDistance(geom1, geom2, densityFrac);
@@ -963,7 +1003,7 @@ public class Functions {
 
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) throws Exception {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object g2) throws Exception {
             Geometry geom1 = (Geometry) g1;
             Geometry geom2 = (Geometry) g2;
             return org.apache.sedona.common.Functions.hausdorffDistance(geom1, geom2);
@@ -991,9 +1031,9 @@ public class Functions {
 
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p2,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p3,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p4) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p2,
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p3,
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p4) {
             Geometry point1 = (Geometry) p1;
             Geometry point2 = (Geometry) p2;
             Geometry point3 = (Geometry) p3;
@@ -1004,8 +1044,8 @@ public class Functions {
 
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p2,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p3) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p2,
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object p3) {
             Geometry point1 = (Geometry) p1;
             Geometry point2 = (Geometry) p2;
             Geometry point3 = (Geometry) p3;
@@ -1015,7 +1055,7 @@ public class Functions {
 
         @DataTypeHint("Double")
         public Double eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object line1,
-                           @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object line2) {
+                @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class) Object line2) {
             Geometry lineString1 = (Geometry) line1;
             Geometry lineString2 = (Geometry) line2;
 
diff --git a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
index 46f6b00bc..411786369 100644
--- a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
+++ b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
@@ -32,6 +32,7 @@ import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import java.util.Arrays;
+import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
@@ -93,7 +94,7 @@ public class FunctionTest extends TestBase{
         table = table.select(call(Functions.ST_ClosestPoint.class.getSimpleName(), $("g1"), $("g2")));
         Geometry result = (Geometry) first(table).getField(0);
         assertEquals("POINT (160 40)", result.toString());
-    }   
+    }
     public void testCentroid() {
         Table polygonTable = tableEnv.sqlQuery("SELECT ST_GeomFromText('POLYGON ((2 2, 0 0, 2 0, 0 2, 2 2))') as geom");
         Table resultTable = polygonTable.select(call(Functions.ST_Centroid.class.getSimpleName(), $("geom")));
@@ -257,7 +258,7 @@ public class FunctionTest extends TestBase{
     @Test
     public void testDimension(){
         Table pointTable = tableEnv.sqlQuery(
-                        "SELECT ST_Dimension(ST_GeomFromWKT('GEOMETRYCOLLECTION EMPTY'))");
+                "SELECT ST_Dimension(ST_GeomFromWKT('GEOMETRYCOLLECTION EMPTY'))");
         assertEquals(0, first(pointTable).getField(0));
 
         pointTable = tableEnv.sqlQuery(
@@ -371,7 +372,7 @@ public class FunctionTest extends TestBase{
     @Test
     public void testGeometryType() {
         Table pointTable = tableEnv.sqlQuery(
-                        "SELECT GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'))");
+                "SELECT GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'))");
         assertEquals("LINESTRING", first(pointTable).getField(0));
 
         pointTable = tableEnv.sqlQuery(
@@ -510,14 +511,14 @@ public class FunctionTest extends TestBase{
         String result = (String) first(polygonTable).getField(0);
         String expected =
                 "<gml:Polygon>\n" +
-                "  <gml:outerBoundaryIs>\n" +
-                "    <gml:LinearRing>\n" +
-                "      <gml:coordinates>\n" +
-                "        -0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5 \n" +
-                "      </gml:coordinates>\n" +
-                "    </gml:LinearRing>\n" +
-                "  </gml:outerBoundaryIs>\n" +
-                "</gml:Polygon>\n";
+                        "  <gml:outerBoundaryIs>\n" +
+                        "    <gml:LinearRing>\n" +
+                        "      <gml:coordinates>\n" +
+                        "        -0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5 \n" +
+                        "      </gml:coordinates>\n" +
+                        "    </gml:LinearRing>\n" +
+                        "  </gml:outerBoundaryIs>\n" +
+                        "</gml:Polygon>\n";
         assertEquals(expected, result);
     }
 
@@ -528,12 +529,12 @@ public class FunctionTest extends TestBase{
         String result = (String) first(polygonTable).getField(0);
         String expected =
                 "<Polygon>\n" +
-                "  <outerBoundaryIs>\n" +
-                "  <LinearRing>\n" +
-                "    <coordinates>-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5</coordinates>\n" +
-                "  </LinearRing>\n" +
-                "  </outerBoundaryIs>\n" +
-                "</Polygon>\n";
+                        "  <outerBoundaryIs>\n" +
+                        "  <LinearRing>\n" +
+                        "    <coordinates>-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5</coordinates>\n" +
+                        "  </LinearRing>\n" +
+                        "  </outerBoundaryIs>\n" +
+                        "</Polygon>\n";
         assertEquals(expected, result);
     }
 
@@ -771,7 +772,7 @@ public class FunctionTest extends TestBase{
         assertEquals("LINESTRING (10 40, 40 30, 20 20, 30 10)", first(pointTable).getField(0).toString());
     }
 
-    @Test 
+    @Test
     public void testLineMerge() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('MULTILINESTRING((10 160, 60 120), (120 140, 60 120), (120 140, 180 120))') AS multiline");
         table = table.select(call(Functions.ST_LineMerge.class.getSimpleName(), $("multiline")));
@@ -779,7 +780,7 @@ public class FunctionTest extends TestBase{
         assertEquals("LINESTRING (10 160, 60 120, 120 140, 180 120)", result.toString());
     }
 
-    @Test 
+    @Test
     public void testLineSubString() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 2 0)') AS line");
         table = table.select(call(Functions.ST_LineSubstring.class.getSimpleName(), $("line"), 0.5, 1.0));
@@ -795,7 +796,7 @@ public class FunctionTest extends TestBase{
         assertEquals("LINESTRING (0 0, 1 1)", result.toString());
     }
 
-    @Test 
+    @Test
     public void testPolygon() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0, 1 1, 0 0)') AS line");
         table = table.select(call(Functions.ST_Polygon.class.getSimpleName(), $("line"), 4236));
@@ -804,7 +805,7 @@ public class FunctionTest extends TestBase{
         assertEquals(4236, result.getSRID());
     }
 
-    @Test 
+    @Test
     public void testMakePolygon() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0, 1 1, 0 0)') AS line");
         table = table.select(call(Functions.ST_MakePolygon.class.getSimpleName(), $("line")));
@@ -812,16 +813,16 @@ public class FunctionTest extends TestBase{
         assertEquals("POLYGON ((0 0, 1 0, 1 1, 0 0))", result.toString());
     }
 
-    @Test 
+    @Test
     public void testMakePolygonWithHoles() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromText('LINESTRING (0 0, 1 0, 1 1, 0 0)') AS line," +
-                                        "array[ST_GeomFromText('LINESTRING (0.5 0.1, 0.7 0.1, 0.7 0.3, 0.5 0.1)')] AS holes");
+                "array[ST_GeomFromText('LINESTRING (0.5 0.1, 0.7 0.1, 0.7 0.3, 0.5 0.1)')] AS holes");
         table = table.select(call(Functions.ST_MakePolygon.class.getSimpleName(), $("line"), $("holes")));
         Geometry result = (Geometry) first(table).getField(0);
         assertEquals("POLYGON ((0 0, 1 0, 1 1, 0 0), (0.5 0.1, 0.7 0.1, 0.7 0.3, 0.5 0.1))", result.toString());
     }
 
-    @Test 
+    @Test
     public void testMakeValid() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('POLYGON ((1 5, 1 1, 3 3, 5 3, 7 1, 7 5, 5 3, 3 3, 1 5))') AS polygon");
         table = table.select(call(Functions.ST_MakeValid.class.getSimpleName(), $("polygon")));
@@ -829,7 +830,7 @@ public class FunctionTest extends TestBase{
         assertEquals("MULTIPOLYGON (((1 5, 3 3, 1 1, 1 5)), ((5 3, 7 5, 7 1, 5 3)))", result.toString());
     }
 
-    @Test 
+    @Test
     public void testMinimumBoundingCircle() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0)') AS geom");
         table = table.select(call(Functions.ST_MinimumBoundingCircle.class.getSimpleName(), $("geom")));
@@ -839,7 +840,7 @@ public class FunctionTest extends TestBase{
         assertEquals(actual, expected);
     }
 
-    @Test 
+    @Test
     public void testMinimumBoundingCircleWithQuadrantSegments() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0)') AS geom");
         table = table.select(call(Functions.ST_MinimumBoundingCircle.class.getSimpleName(), $("geom"), 2));
@@ -849,7 +850,7 @@ public class FunctionTest extends TestBase{
         assertEquals(actual, expected);
     }
 
-    @Test 
+    @Test
     public void testMinimumBoundingRadius() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0)') AS geom");
         table = table.select(call(Functions.ST_MinimumBoundingRadius.class.getSimpleName(), $("geom")));
@@ -858,7 +859,7 @@ public class FunctionTest extends TestBase{
         assertEquals(0.5, result.getRight(), 1e-6);
     }
 
-    @Test 
+    @Test
     public void testMulti() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('POINT (0 0)') AS geom");
         table = table.select(call(Functions.ST_Multi.class.getSimpleName(), $("geom")));
@@ -866,7 +867,7 @@ public class FunctionTest extends TestBase{
         assertEquals("MULTIPOINT ((0 0))", result.toString());
     }
 
-    @Test 
+    @Test
     public void testStartPoint() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0)') AS geom");
         table = table.select(call(Functions.ST_StartPoint.class.getSimpleName(), $("geom")));
@@ -874,7 +875,7 @@ public class FunctionTest extends TestBase{
         assertEquals("POINT (0 0)", result.toString());
     }
 
-    @Test 
+    @Test
     public void testSimplifyPreserveTopology() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('POLYGON ((0 0, 1 0, 1 0.9, 1 1, 0 0))') AS geom");
         table = table.select(call(Functions.ST_SimplifyPreserveTopology.class.getSimpleName(), $("geom"), 0.2));
@@ -888,7 +889,7 @@ public class FunctionTest extends TestBase{
         assertEquals("MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 1 1), (1 1, 1.5 1.5, 2 2))", ((Geometry)first(pointTable).getField(0)).norm().toText());
     }
 
-    @Test 
+    @Test
     public void testSubdivide() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)') AS geom");
         table = table.select(call(Functions.ST_Subdivide.class.getSimpleName(), $("geom"), 5));
@@ -897,7 +898,7 @@ public class FunctionTest extends TestBase{
         assertEquals("LINESTRING (2.5 0, 5 0)", result[1].toString());
     }
 
-    @Test 
+    @Test
     public void testSymDifference() {
         Table table = tableEnv.sqlQuery("SELECT ST_GeomFromWKT('POLYGON ((-1 -1, 1 -1, 1 1, -1 1, -1 -1))') AS a, ST_GeomFromWKT('POLYGON ((0 -2, 2 -2, 2 0, 0 0, 0 -2))') AS b");
         table = table.select(call(Functions.ST_SymDifference.class.getSimpleName(), $("a"), $("b")));
@@ -937,6 +938,60 @@ public class FunctionTest extends TestBase{
         assertEquals(2, first(joinCleanedTable).getField(1));
     }
 
+    @Test
+    public void testH3CellIDs() {
+        String initExplodeQuery = "SELECT id, geom, cell_tbl.cell from (VALUES %s) as raw_tbl(id, geom, cells) CROSS JOIN UNNEST(raw_tbl.cells) AS cell_tbl (cell)";
+        // left is a polygon
+        tableEnv.createTemporaryView(
+                "lefts_h3",
+                tableEnv.sqlQuery(String.format(initExplodeQuery, "(1, ST_GeomFromWKT('POLYGON ((0 0, 0.2 0, 0.2 0.2, 0 0.2, 0 0))'), ST_H3CellIDs(ST_GeomFromWKT('POLYGON ((0 0, 0.2 0, 0.2 0.2, 0 0.2, 0 0))'), 8, true))"))
+        );
+        // points for test
+        String points = String.join(", ", new String[] {
+                "(2, ST_GeomFromWKT('POINT (0.1 0.1)'), ST_H3CellIDs(ST_GeomFromWKT('POINT (0.1 0.1)'), 8, true))", // points within polygon
+                "(3, ST_GeomFromWKT('POINT (0.25 0.1)'), ST_H3CellIDs(ST_GeomFromWKT('POINT (0.25 0.1)'), 8, true))", // points outside of polygon
+                "(4, ST_GeomFromWKT('POINT (0.2005 0.1)'), ST_H3CellIDs(ST_GeomFromWKT('POINT (0.2005 0.1)'), 8, true))" // points outside of polygon, but very close to border
+        });
+        tableEnv.createTemporaryView(
+                "rights_h3",
+                tableEnv.sqlQuery(String.format(initExplodeQuery, points))
+        );
+        Table joinTable = tableEnv.sqlQuery("select lefts_h3.id, rights_h3.id from lefts_h3 join rights_h3 on lefts_h3.cell = rights_h3.cell group by (lefts_h3.id, rights_h3.id)");
+        assertEquals(2, count(joinTable));
+        ;
+        assert take(joinTable, 2).stream().map(
+                r -> Objects.requireNonNull(r.getField(1)).toString()
+        ).collect(Collectors.toSet()).containsAll(Arrays.asList("2", "4"));
+        // This is due to under level = 10, point id = 4 fall into same cell as the boarder of polygon id = 1
+        // join and filter by st_intersects to exclude the wrong join
+        Table joinCleanedTable = tableEnv.sqlQuery("select lefts_h3.id, rights_h3.id from lefts_h3 join rights_h3 on lefts_h3.cell = rights_h3.cell where ST_Intersects(lefts_h3.geom, rights_h3.geom) is true group by (lefts_h3.id, rights_h3.id)");
+        // after filter by ST_Intersects, only id =2 point
+        assertEquals(1, count(joinCleanedTable));
+        assertEquals(2, first(joinCleanedTable).getField(1));
+    }
+
+    @Test
+    public void testH3CellDistance() {
+        Table pointTable = tableEnv.sqlQuery("select ST_H3CellDistance(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], ST_H3CellIDs(ST_GeomFromWKT('POINT(1.23 1.59)'), 8, true)[1])");
+        long exact = Long.parseLong(Objects.requireNonNull(first(pointTable).getField(0)).toString());
+        assertEquals(exact, 78);
+    }
+
+    @Test
+    public void testH3KRing() {
+        Table pointTable = tableEnv.sqlQuery("select ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 3, false), ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[1], 3, true)");
+        List<Long> full = Arrays.asList((Long[]) Objects.requireNonNull(first(pointTable).getField(0)));
+        List<Long> exactRing = Arrays.asList((Long[]) Objects.requireNonNull(first(pointTable).getField(0)));
+        assert full.containsAll(exactRing);
+    }
+
+    @Test
+    public void testH3ToGeom() {
+            Table pointTable = tableEnv.sqlQuery("select ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true))");
+        Geometry exact = (Geometry) Objects.requireNonNull(first(pointTable).getField(0));
+        assertEquals(exact.getNumGeometries(), 1);
+    }
+
     @Test
     public void testGeometricMedian() throws ParseException {
         Table pointTable = tableEnv.sqlQuery("SELECT ST_GeometricMedian(ST_GeomFromWKT('MULTIPOINT((0 0), (1 1), (2 2), (200 200))'))");
@@ -978,7 +1033,7 @@ public class FunctionTest extends TestBase{
     public void testForce3D() {
         Integer expectedDims = 3;
         Table pointTable = tableEnv.sqlQuery("SELECT ST_Force3D(ST_GeomFromWKT('LINESTRING(0 1, 1 0, 2 0)'), 1.2) " +
-                                                "AS " + polygonColNames[0]);
+                "AS " + polygonColNames[0]);
         pointTable = pointTable.select(call(Functions.ST_NDims.class.getSimpleName(), $(polygonColNames[0])));
         Integer actual = (Integer) first(pointTable).getField(0);
         assertEquals(expectedDims, actual);
@@ -1016,11 +1071,11 @@ public class FunctionTest extends TestBase{
         Table polyTable1 = tableEnv.sqlQuery("SELECT ST_VoronoiPolygons(ST_GeomFromWKT('MULTIPOINT ((0 0), (2 2))'))");
         Geometry result = (Geometry) first(polyTable1).getField(0);
         assertEquals("GEOMETRYCOLLECTION (POLYGON ((-2 -2, -2 4, 4 -2, -2 -2)), POLYGON ((-2 4, 4 4, 4 -2, -2 4)))", result.toString());
-        
+
         Table polyTable2 = tableEnv.sqlQuery("SELECT ST_VoronoiPolygons(ST_GeomFromWKT('MULTIPOINT ((0 0), (2 2))'), 0, ST_Buffer(ST_GeomFromWKT('POINT(1 1)'), 10.0) )");
         result = (Geometry) first(polyTable2).getField(0);
         assertEquals("GEOMETRYCOLLECTION (POLYGON ((-9 -9, -9 11, 11 -9, -9 -9)), POLYGON ((-9 11, 11 11, 11 -9, -9 11)))", result.toString());
-    
+
         Table polyTable3 = tableEnv.sqlQuery("SELECT ST_VoronoiPolygons(ST_GeomFromWKT('MULTIPOINT ((0 0), (2 2))'), 30)");
         result = (Geometry) first(polyTable3).getField(0);
         assertEquals("GEOMETRYCOLLECTION (POLYGON ((-2 -2, -2 4, 4 4, 4 -2, -2 -2)))", result.toString());
@@ -1028,7 +1083,7 @@ public class FunctionTest extends TestBase{
         Table polyTable4 = tableEnv.sqlQuery("SELECT ST_VoronoiPolygons(ST_GeomFromWKT('MULTIPOINT ((0 0), (2 2))'), 30, ST_Buffer(ST_GeomFromWKT('POINT(1 1)'), 10) )");
         result = (Geometry) first(polyTable4).getField(0);
         assertEquals("GEOMETRYCOLLECTION (POLYGON ((-9 -9, -9 11, 11 11, 11 -9, -9 -9)))", result.toString());
-        
+
         Table polyTable5 = tableEnv.sqlQuery("SELECT ST_VoronoiPolygons(null, 30, ST_Buffer(ST_GeomFromWKT('POINT(1 1)'), 10))");
         result = (Geometry) first(polyTable5).getField(0);
         assertEquals(null, result);
diff --git a/pom.xml b/pom.xml
index d92d02cea..012cc3e60 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,7 @@
 
         <slf4j.version>1.7.36</slf4j.version>
         <googles2.version>2.0.0</googles2.version>
+        <uberh3.version>4.1.1</uberh3.version>
         <scalatest.version>3.1.1</scalatest.version>
         <scala-collection-compat.version>2.5.0</scala-collection-compat.version>
         <geoglib.version>1.52</geoglib.version>
@@ -329,6 +330,11 @@
                 <artifactId>s2-geometry</artifactId>
                 <version>${googles2.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.uber</groupId>
+                <artifactId>h3</artifactId>
+                <version>${uberh3.version}</version>
+            </dependency>
             <dependency>
                 <groupId>net.sf.geographiclib</groupId>
                 <artifactId>GeographicLib-Java</artifactId>
diff --git a/python/sedona/sql/st_functions.py b/python/sedona/sql/st_functions.py
index a3da02c03..0f5ad4a43 100644
--- a/python/sedona/sql/st_functions.py
+++ b/python/sedona/sql/st_functions.py
@@ -62,6 +62,10 @@ __all__ = [
     "ST_GeometricMedian",
     "ST_GeometryN",
     "ST_GeometryType",
+    "ST_H3CellDistance",
+    "ST_H3CellIDs",
+    "ST_H3KRing",
+    "ST_H3ToGeom",
     "ST_InteriorRingN",
     "ST_Intersection",
     "ST_IsClosed",
@@ -383,7 +387,7 @@ def ST_CollectionExtract(collection: ColumnOrName, geom_type: Optional[Union[Col
 
 @validate_argument_types
 def ST_ClosestPoint(a: ColumnOrName, b: ColumnOrName) -> Column:
-    """Returns the 2-dimensional point on geom1 that is closest to geom2. 
+    """Returns the 2-dimensional point on geom1 that is closest to geom2.
     This is the first point of the shortest line between the geometries.
 
     :param a: Geometry column to use in the calculation.
@@ -594,8 +598,8 @@ def ST_GeoHash(geometry: ColumnOrName, precision: Union[ColumnOrName, int]) -> C
 
 @validate_argument_types
 def ST_GeometricMedian(geometry: ColumnOrName, tolerance: Optional[Union[ColumnOrName, float]] = 1e-6,
-                       max_iter: Optional[Union[ColumnOrName, int]] = 1000,
-                       fail_if_not_converged: Optional[Union[ColumnOrName, bool]] = False) -> Column:
+        max_iter: Optional[Union[ColumnOrName, int]] = 1000,
+        fail_if_not_converged: Optional[Union[ColumnOrName, bool]] = False) -> Column:
     """Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm.
     The geometric median provides a centrality measure that is less sensitive to outlier points than the centroid.
     The algorithm will iterate until the distance change between successive iterations is less than the
@@ -647,6 +651,62 @@ def ST_GeometryType(geometry: ColumnOrName) -> Column:
     return _call_st_function("ST_GeometryType", geometry)
 
 
+@validate_argument_types
+def ST_H3CellDistance(cell1: Union[ColumnOrName, int], cell2: Union[ColumnOrName, int]) -> Column:
+    """Cover Geometry with H3 Cells and return a List of Long type cell IDs
+    :param cell: start cell
+    :type cell: long
+    :param k: end cell
+    :type k: int
+    :return: distance between cells
+    :rtype: Long
+    """
+    args = (cell1, cell2)
+    return _call_st_function("ST_H3CellDistance", args)
+
+
+@validate_argument_types
+def ST_H3CellIDs(geometry: ColumnOrName, level: Union[ColumnOrName, int], full_cover: Union[ColumnOrName, bool]) -> Column:
+    """Cover Geometry with H3 Cells and return a List of Long type cell IDs
+    :param geometry: Geometry column to generate cell IDs
+    :type geometry: ColumnOrName
+    :param level: value between 1 and 15, controls the size of the cells used for coverage. With a bigger level, the cells will be smaller, the coverage will be more accurate, but the result size will be exponentially increasing.
+    :type level: int
+    :param full_cover: ColumnOrName
+    :type full_cover: int
+    :return: List of cellIDs
+    :rtype: List[long]
+    """
+    args = (geometry, level, full_cover)
+    return _call_st_function("ST_H3CellIDs", args)
+
+
+@validate_argument_types
+def ST_H3KRing(cell: Union[ColumnOrName, int], k: Union[ColumnOrName, int], exact_ring: Union[ColumnOrName, bool]) -> Column:
+    """Cover Geometry with H3 Cells and return a List of Long type cell IDs
+    :param cell: original cell
+    :type cell: long
+    :param k: the k number of rings spread from the original cell
+    :type k: int
+    :param exact_ring: if exactDistance is true, it will only return the cells on the exact kth ring, else will return all 0 - kth neighbors
+    :type exact_ring: bool
+    :return: List of cellIDs
+    :rtype: List[long]
+    """
+    args = (cell, k, exact_ring)
+    return _call_st_function("ST_H3KRing", args)
+
+
+@validate_argument_types
+def ST_H3ToGeom(cells: Union[ColumnOrName, list]) -> Column:
+    """Cover Geometry with H3 Cells and return a List of Long type cell IDs
+    :param cells: h3 cells
+    :return: the reversed multipolygon
+    :rtype: Geometry
+    """
+    return _call_st_function("ST_H3ToGeom", cells)
+
+
 @validate_argument_types
 def ST_InteriorRingN(polygon: ColumnOrName, n: Union[ColumnOrName, int]) -> Column:
     """Return the index n (0-th based) interior ring of a polygon geometry column.
@@ -1036,6 +1096,7 @@ def ST_Reverse(geometry: ColumnOrName) -> Column:
     """
     return _call_st_function("ST_Reverse", geometry)
 
+
 @validate_argument_types
 def ST_S2CellIDs(geometry: ColumnOrName, level: Union[ColumnOrName, int]) -> Column:
     """Cover Geometry with S2 Cells and return a List of Long type cell IDs
@@ -1383,9 +1444,9 @@ def ST_FrechetDistance(g1: ColumnOrName, g2: ColumnOrName) -> Column:
 
 @validate_argument_types
 def ST_Affine(geometry: ColumnOrName, a: Union[ColumnOrName, float], b: Union[ColumnOrName, float], d: Union[ColumnOrName, float],
-                e: Union[ColumnOrName, float], xOff: Union[ColumnOrName, float], yOff: Union[ColumnOrName, float], c: Optional[Union[ColumnOrName, float]] = None, f: Optional[Union[ColumnOrName, float]] = None,
-                g: Optional[Union[ColumnOrName, float]] = None, h: Optional[Union[ColumnOrName, float]] = None,
-                i: Optional[Union[ColumnOrName, float]] = None,  zOff: Optional[Union[ColumnOrName, float]] = None) -> Column:
+        e: Union[ColumnOrName, float], xOff: Union[ColumnOrName, float], yOff: Union[ColumnOrName, float], c: Optional[Union[ColumnOrName, float]] = None, f: Optional[Union[ColumnOrName, float]] = None,
+        g: Optional[Union[ColumnOrName, float]] = None, h: Optional[Union[ColumnOrName, float]] = None,
+        i: Optional[Union[ColumnOrName, float]] = None,  zOff: Optional[Union[ColumnOrName, float]] = None) -> Column:
     """
     Apply a 3D/2D affine transformation to the given geometry
     x = a * x + b * y + c * z + xOff | x = a * x + b * y + xOff
diff --git a/python/tests/sql/test_function.py b/python/tests/sql/test_function.py
index 686771b6b..948972c42 100644
--- a/python/tests/sql/test_function.py
+++ b/python/tests/sql/test_function.py
@@ -266,10 +266,10 @@ class TestPredicateJoin(TestBase):
             ("Linestring(0 0 1, 1 1 2, 1 0 3)",),
             ("MULTIPOINT ((10 40 66), (40 30 77), (20 20 88), (30 10 99))",),
             (
-            "MULTIPOLYGON (((30 20 11, 45 40 11, 10 40 11, 30 20 11)), ((15 5 11, 40 10 11, 10 20 11, 5 10 11, 15 5 11)))",),
+                "MULTIPOLYGON (((30 20 11, 45 40 11, 10 40 11, 30 20 11)), ((15 5 11, 40 10 11, 10 20 11, 5 10 11, 15 5 11)))",),
             ("MULTILINESTRING ((10 10 11, 20 20 11, 10 40 11), (40 40 11, 30 30 11, 40 20 11, 30 10 11))",),
             (
-            "MULTIPOLYGON (((40 40 11, 20 45 11, 45 30 11, 40 40 11)), ((20 35 11, 10 30 11, 10 10 11, 30 5 11, 45 20 11, 20 35 11), (30 20 11, 20 15 11, 20 25 11, 30 20 11)))",),
+                "MULTIPOLYGON (((40 40 11, 20 45 11, 45 30 11, 40 40 11)), ((20 35 11, 10 30 11, 10 10 11, 30 5 11, 45 20 11, 20 35 11), (30 20 11, 20 15 11, 20 25 11, 30 20 11)))",),
             ("POLYGON((0 0 11, 0 5 11, 5 5 11, 5 0 11, 0 0 11), (1 1 11, 2 1 11, 2 2 11, 1 2 11, 1 1 11))",),
         ], ["wkt"])
 
@@ -715,8 +715,8 @@ class TestPredicateJoin(TestBase):
             ("MULTILINESTRING ((10 10, 20 20, 10 40, 10 10), (40 40, 30 30, 40 20, 30 10))", "Point(21 52)"),
             ("MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))", "Point(21 52)"),
             (
-            "GEOMETRYCOLLECTION (POINT (40 10), LINESTRING (10 10, 20 20, 10 40), POLYGON ((40 40, 20 45, 45 30, 40 40)))",
-            "Point(21 52)"),
+                "GEOMETRYCOLLECTION (POINT (40 10), LINESTRING (10 10, 20 20, 10 40), POLYGON ((40 40, 20 45, 45 30, 40 40)))",
+                "Point(21 52)"),
             ("POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))", "Point(21 52)")
         ]
         geometry_df = self.__wkt_pairs_to_data_frame(geometry)
@@ -1156,6 +1156,53 @@ class TestPredicateJoin(TestBase):
         cell_ids = self.spark.sql("select ST_S2CellIDs(null, 6)").take(1)[0][0]
         assert cell_ids is None
 
+    def test_st_h3_cell_ids(self):
+        test_cases = [
+            "'POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))'",
+            "'LINESTRING(0 0, 1 2, 2 4, 3 6)'",
+            "'POINT(1 2)'"
+        ]
+        for input_geom in test_cases:
+            cell_ids = self.spark.sql("select ST_H3CellIDs(ST_GeomFromText({}), 6, true)".format(input_geom)).take(1)[0][0]
+            assert isinstance(cell_ids, list)
+            assert isinstance(cell_ids[0], int)
+        # test null case
+        cell_ids = self.spark.sql("select ST_H3CellIDs(null, 6, true)").take(1)[0][0]
+        assert cell_ids is None
+
+    def test_st_h3_cell_distance(self):
+        df = self.spark.sql("select ST_H3CellDistance(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], ST_H3CellIDs(ST_GeomFromWKT('POINT(1.23 1.59)'), 8, true)[0])")
+        assert df.take(1)[0][0] == 78
+
+    def test_st_h3_kring(self):
+        df = self.spark.sql("""
+        SELECT 
+            ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, true) exactRings,
+            ST_H3KRing(ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true)[0], 1, false) allRings,
+            ST_H3CellIDs(ST_GeomFromWKT('POINT(1 2)'), 8, true) original_cells
+        """)
+        exact_rings, all_rings, original_cells = df.take(1)[0]
+        assert set(exact_rings + original_cells) == set(all_rings)
+
+    def test_st_h3_togeom(self):
+        df = self.spark.sql("""
+        SELECT
+            ST_Contains(
+                ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))'), 6, true)),
+                ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))')
+            ),
+            ST_Contains(
+                ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))'), 6, false)),
+                ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))')
+            ),
+            ST_Intersects(
+                ST_H3ToGeom(ST_H3CellIDs(ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))'), 6, false)),
+                ST_GeomFromText('POLYGON((-1 0, 1 0, 0 0, 0 1, -1 0))')
+            )
+        """)
+        res1, res2, res3 = df.take(1)[0]
+        assert res1 and not res2 and res3
+
     def test_st_numPoints(self):
         actual = self.spark.sql("SELECT ST_NumPoints(ST_GeomFromText('LINESTRING(0 1, 1 0, 2 0)'))").take(1)[0][0]
         expected = 3
diff --git a/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala b/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
index f359d1484..b757ba0be 100644
--- a/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
+++ b/spark/common/src/main/scala/org/apache/sedona/sql/UDF/Catalog.scala
@@ -109,6 +109,10 @@ object Catalog {
     function[ST_EndPoint](),
     function[ST_ExteriorRing](),
     function[ST_GeometryN](),
+    function[ST_H3CellDistance](),
+    function[ST_H3CellIDs](),
+    function[ST_H3ToGeom](),
+    function[ST_H3KRing](),
     function[ST_InteriorRingN](),
     function[ST_Dump](),
     function[ST_DumpPoints](),
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
index 0bfedc38d..5e2b4e118 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
@@ -31,8 +31,6 @@ import org.locationtech.jts.algorithm.MinimumBoundingCircle
 import org.locationtech.jts.geom._
 import org.apache.spark.sql.sedona_sql.expressions.InferrableFunctionConverter._
 
-import java.lang
-
 /**
   * Return the distance between two geometries.
   *
@@ -67,7 +65,7 @@ case class ST_YMin(inputExpressions: Seq[Expression])
   * Return the Z maxima of the geometry.
   *
   * @param inputExpressions This function takes a geometry and returns the maximum of all Z-coordinate values.
-*/
+  */
 case class ST_ZMax(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.zMax _) {
 
@@ -77,10 +75,10 @@ case class ST_ZMax(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the Z minima of the geometry.
- *
- * @param inputExpressions This function takes a geometry and returns the minimum of all Z-coordinate values.
-*/
+  * Return the Z minima of the geometry.
+  *
+  * @param inputExpressions This function takes a geometry and returns the minimum of all Z-coordinate values.
+  */
 case class ST_ZMin(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.zMin _) {
 
@@ -98,10 +96,10 @@ case class ST_3DDistance(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the concave hull of a Geometry.
- *
- * @param inputExpressions
- */
+  * Return the concave hull of a Geometry.
+  *
+  * @param inputExpressions
+  */
 case class ST_ConcaveHull(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.concaveHull _) {
 
@@ -483,11 +481,11 @@ case class ST_MinimumBoundingCircle(inputExpressions: Seq[Expression])
 
 
 /**
- * Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length.
- * Second and third arguments are Double values between 0 and 1. This only works with LINESTRINGs.
- *
- * @param inputExpressions
- */
+  * Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length.
+  * Second and third arguments are Double values between 0 and 1. This only works with LINESTRINGs.
+  *
+  * @param inputExpressions
+  */
 case class ST_LineSubstring(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.lineSubString _) {
 
@@ -497,12 +495,12 @@ case class ST_LineSubstring(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns a point interpolated along a line. First argument must be a LINESTRING.
- * Second argument is a Double between 0 and 1 representing fraction of
- * total linestring length the point has to be located.
- *
- * @param inputExpressions
- */
+  * Returns a point interpolated along a line. First argument must be a LINESTRING.
+  * Second argument is a Double between 0 and 1 representing fraction of
+  * total linestring length the point has to be located.
+  *
+  * @param inputExpressions
+  */
 case class ST_LineInterpolatePoint(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.lineInterpolatePoint _) {
 
@@ -721,10 +719,10 @@ case class ST_GeoHash(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the difference between geometry A and B
- *
- * @param inputExpressions
- */
+  * Return the difference between geometry A and B
+  *
+  * @param inputExpressions
+  */
 case class ST_Difference(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.difference _) {
 
@@ -734,10 +732,10 @@ case class ST_Difference(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the symmetrical difference between geometry A and B
- *
- * @param inputExpressions
- */
+  * Return the symmetrical difference between geometry A and B
+  *
+  * @param inputExpressions
+  */
 case class ST_SymDifference(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.symDifference _) {
 
@@ -747,10 +745,10 @@ case class ST_SymDifference(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the union of geometry A and B
- *
- * @param inputExpressions
- */
+  * Return the union of geometry A and B
+  *
+  * @param inputExpressions
+  */
 case class ST_Union(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.union _) {
 
@@ -768,10 +766,10 @@ case class ST_Multi(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns a POINT guaranteed to lie on the surface.
- *
- * @param inputExpressions Geometry
- */
+  * Returns a POINT guaranteed to lie on the surface.
+  *
+  * @param inputExpressions Geometry
+  */
 case class ST_PointOnSurface(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.pointOnSurface _) {
 
@@ -781,10 +779,10 @@ case class ST_PointOnSurface(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns the geometry with vertex order reversed
- *
- * @param inputExpressions
- */
+  * Returns the geometry with vertex order reversed
+  *
+  * @param inputExpressions
+  */
 case class ST_Reverse(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.reverse _) {
 
@@ -794,23 +792,23 @@ case class ST_Reverse(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns the nth point in the geometry, provided it is a linestring
- *
- * @param inputExpressions sequence of 2 input arguments, a geometry and a value 'n'
- */
+  * Returns the nth point in the geometry, provided it is a linestring
+  *
+  * @param inputExpressions sequence of 2 input arguments, a geometry and a value 'n'
+  */
 case class ST_PointN(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.pointN _) {
 
   protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
-      copy(inputExpressions = newChildren)
+    copy(inputExpressions = newChildren)
   }
 }
 
- /*
- * Forces the geometries into a "2-dimensional mode" so that all output representations will only have the X and Y coordinates.
- *
- * @param inputExpressions
- */
+/*
+* Forces the geometries into a "2-dimensional mode" so that all output representations will only have the X and Y coordinates.
+*
+* @param inputExpressions
+*/
 case class ST_Force_2D(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.force2D _) {
 
@@ -820,10 +818,10 @@ case class ST_Force_2D(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns the geometry in EWKT format
- *
- * @param inputExpressions
- */
+  * Returns the geometry in EWKT format
+  *
+  * @param inputExpressions
+  */
 case class ST_AsEWKT(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.asEWKT _) {
 
@@ -849,10 +847,10 @@ case class ST_AsKML(inputExpressions: Seq[Expression])
 }
 
 /**
- * Test if Geometry is empty geometry.
- *
- * @param inputExpressions
- */
+  * Test if Geometry is empty geometry.
+  *
+  * @param inputExpressions
+  */
 case class ST_IsEmpty(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.isEmpty _) {
 
@@ -862,10 +860,10 @@ case class ST_IsEmpty(inputExpressions: Seq[Expression])
 }
 
 /**
- * Test if returning Max X coordinate value.
- *
- * @param inputExpressions
- */
+  * Test if returning Max X coordinate value.
+  *
+  * @param inputExpressions
+  */
 case class ST_XMax(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.xMax _) {
 
@@ -875,10 +873,10 @@ case class ST_XMax(inputExpressions: Seq[Expression])
 }
 
 /**
- * Test if returning Min X coordinate value.
- *
- * @param inputExpressions
- */
+  * Test if returning Min X coordinate value.
+  *
+  * @param inputExpressions
+  */
 case class ST_XMin(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.xMin _) {
 
@@ -889,10 +887,10 @@ case class ST_XMin(inputExpressions: Seq[Expression])
 
 
 /**
- * Returns the areal geometry formed by the constituent linework of the input geometry assuming all inner geometries represent holes
- *
- * @param inputExpressions
- */
+  * Returns the areal geometry formed by the constituent linework of the input geometry assuming all inner geometries represent holes
+  *
+  * @param inputExpressions
+  */
 case class ST_BuildArea(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.buildArea _) {
 
@@ -902,10 +900,10 @@ case class ST_BuildArea(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns the input geometry in its normalized form.
- *
- * @param inputExpressions
- */
+  * Returns the input geometry in its normalized form.
+  *
+  * @param inputExpressions
+  */
 case class ST_Normalize(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.normalize _) {
 
@@ -915,10 +913,10 @@ case class ST_Normalize(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns the LineString geometry given a MultiPoint geometry
- *
- * @param inputExpressions
- */
+  * Returns the LineString geometry given a MultiPoint geometry
+  *
+  * @param inputExpressions
+  */
 case class ST_LineFromMultiPoint(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.lineFromMultiPoint _) {
 
@@ -928,10 +926,10 @@ case class ST_LineFromMultiPoint(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns a multi-geometry that is the result of splitting the input geometry by the blade geometry
- *
- * @param inputExpressions
- */
+  * Returns a multi-geometry that is the result of splitting the input geometry by the blade geometry
+  *
+  * @param inputExpressions
+  */
 case class ST_Split(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.split _) {
 
@@ -948,6 +946,38 @@ case class ST_S2CellIDs(inputExpressions: Seq[Expression])
   }
 }
 
+case class ST_H3CellIDs(inputExpressions: Seq[Expression])
+  extends InferredExpression(Functions.h3CellIDs _) {
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
+    copy(inputExpressions = newChildren)
+  }
+}
+
+case class ST_H3CellDistance(inputExpressions: Seq[Expression])
+  extends InferredExpression(Functions.h3CellDistance _) {
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
+    copy(inputExpressions = newChildren)
+  }
+}
+
+case class ST_H3KRing(inputExpressions: Seq[Expression])
+  extends InferredExpression(Functions.h3KRing _) {
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
+    copy(inputExpressions = newChildren)
+  }
+}
+
+case class ST_H3ToGeom(inputExpressions: Seq[Expression])
+  extends InferredExpression(Functions.h3ToGeom _) with FoldableExpression {
+
+  protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
+    copy(inputExpressions = newChildren)
+  }
+}
+
 case class ST_CollectionExtract(inputExpressions: Seq[Expression])
   extends InferredExpression(InferrableFunction.allowRightNull(Functions.collectionExtract)) {
 
@@ -956,12 +986,13 @@ case class ST_CollectionExtract(inputExpressions: Seq[Expression])
   }
 }
 
+
 /**
- * Returns a POINT Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm.
- * The geometric median provides a centrality measure that is less sensitive to outlier points than the centroid.
- *
- * @param inputExpressions Geometry
- */
+  * Returns a POINT Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm.
+  * The geometric median provides a centrality measure that is less sensitive to outlier points than the centroid.
+  *
+  * @param inputExpressions Geometry
+  */
 case class ST_GeometricMedian(inputExpressions: Seq[Expression])
   extends InferredExpression(inferrableFunction4(Functions.geometricMedian)) with FoldableExpression {
 
@@ -1095,10 +1126,10 @@ case class ST_Degrees(inputExpressions: Seq[Expression])
 }
 
 /**
- * Return the number of ddimensions in geometry.
- *
- * @param inputExpressions
- * */
+  * Return the number of ddimensions in geometry.
+  *
+  * @param inputExpressions
+  * */
 case class ST_CoordDim(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.nDims _) {
   protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]): Expression = {
@@ -1107,10 +1138,10 @@ case class ST_CoordDim(inputExpressions: Seq[Expression])
 }
 
 /**
- * Returns True if geometry is a collection of geometries
- *
- * @param inputExpressions
- */
+  * Returns True if geometry is a collection of geometries
+  *
+  * @param inputExpressions
+  */
 case class ST_IsCollection(inputExpressions: Seq[Expression])
   extends InferredExpression(Functions.isCollection _) {
   protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]): Expression = {
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala
index 79b324588..4bb91c876 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/InferredExpression.scala
@@ -80,12 +80,16 @@ object InferrableType {
     new InferrableType[Geometry] {}
   implicit val gridCoverage2DInstance: InferrableType[GridCoverage2D] =
     new InferrableType[GridCoverage2D] {}
+  implicit val gridCoverage2DArrayInstance: InferrableType[Array[GridCoverage2D]] =
+    new InferrableType[Array[GridCoverage2D]] {}
   implicit val geometryArrayInstance: InferrableType[Array[Geometry]] =
     new InferrableType[Array[Geometry]] {}
   implicit val javaDoubleInstance: InferrableType[java.lang.Double] =
     new InferrableType[java.lang.Double] {}
   implicit val javaIntegerInstance: InferrableType[java.lang.Integer] =
     new InferrableType[java.lang.Integer] {}
+  implicit val javaLongInstance: InferrableType[java.lang.Long] =
+    new InferrableType[java.lang.Long] {}
   implicit val doubleInstance: InferrableType[Double] =
     new InferrableType[Double] {}
   implicit val booleanInstance: InferrableType[Boolean] =
@@ -94,20 +98,22 @@ object InferrableType {
     new InferrableType[Option[Boolean]] {}
   implicit val intInstance: InferrableType[Int] =
     new InferrableType[Int] {}
+  implicit val longInstance: InferrableType[Long] =
+    new InferrableType[Long] {}
   implicit val stringInstance: InferrableType[String] =
     new InferrableType[String] {}
   implicit val binaryInstance: InferrableType[Array[Byte]] =
     new InferrableType[Array[Byte]] {}
-  implicit val longArrayInstance: InferrableType[Array[java.lang.Long]] =
-    new InferrableType[Array[java.lang.Long]] {}
   implicit val intArrayInstance: InferrableType[Array[Int]] =
     new InferrableType[Array[Int]] {}
   implicit val javaIntArrayInstance: InferrableType[Array[java.lang.Integer]] =
     new InferrableType[Array[java.lang.Integer]]
+  implicit val longArrayInstance: InferrableType[Array[Long]] =
+    new InferrableType[Array[Long]] {}
+  implicit val javaLongArrayInstance: InferrableType[Array[java.lang.Long]] =
+    new InferrableType[Array[java.lang.Long]] {}
   implicit val doubleArrayInstance: InferrableType[Array[Double]] =
     new InferrableType[Array[Double]] {}
-  implicit val longInstance: InferrableType[Long] =
-    new InferrableType[Long] {}
 }
 
 object InferredTypes {
@@ -122,11 +128,17 @@ object InferredTypes {
       expr => input => expr.eval(input).asInstanceOf[ArrayData].toDoubleArray()
     } else if (t =:= typeOf[String]) {
       expr => input => expr.asString(input)
+    } else if (t =:= typeOf[Array[Long]]) {
+      expr => input => expr.eval(input).asInstanceOf[ArrayData].toLongArray()
+    } else if (t =:= typeOf[Array[Int]]) {
+      expr => input => expr.eval(input).asInstanceOf[ArrayData] match {
+        case null => null
+        case arrayData: ArrayData => arrayData.toIntArray()
+      }
     } else {
       expr => input => expr.eval(input)
     }
   }
-
   def buildSerializer(t: Type): Any => Any = {
     if (t =:= typeOf[Geometry]) {
       output =>
@@ -150,7 +162,7 @@ object InferredTypes {
         } else {
           null
         }
-    } else if (t =:= typeOf[Array[java.lang.Long]] || t =:= typeOf[Array[Double]]) {
+    } else if (t =:= typeOf[Array[java.lang.Long]] || t =:= typeOf[Array[Long]] || t =:= typeOf[Array[Double]]) {
       output =>
         if (output != null) {
           ArrayData.toArrayData(output)
@@ -183,6 +195,8 @@ object InferredTypes {
       DataTypes.createArrayType(GeometryUDT)
     } else if (t =:= typeOf[GridCoverage2D]) {
       RasterUDT
+    } else if (t =:= typeOf[Array[GridCoverage2D]]) {
+      DataTypes.createArrayType(RasterUDT)
     } else if (t =:= typeOf[java.lang.Double]) {
       DoubleType
     } else if (t =:= typeOf[java.lang.Integer]) {
@@ -191,24 +205,24 @@ object InferredTypes {
       DoubleType
     } else if (t =:= typeOf[Int]) {
       IntegerType
-    } else if (t =:= typeOf[Long]) {
+    } else if (t =:= typeOf[Long] || t =:= typeOf[java.lang.Long]) {
       LongType
     } else if (t =:= typeOf[String]) {
       StringType
     } else if (t =:= typeOf[Array[Byte]]) {
       BinaryType
-    } else if (t =:= typeOf[Array[Int]]) {
+    } else if (t =:= typeOf[Array[Int]] || t =:= typeOf[Array[java.lang.Integer]]) {
       DataTypes.createArrayType(IntegerType)
-    } else if (t =:= typeOf[Array[java.lang.Integer]]) {
-      DataTypes.createArrayType(IntegerType)
-    } else if (t =:= typeOf[Array[java.lang.Long]]) {
+    } else if (t =:= typeOf[Array[Long]] || t =:= typeOf[Array[java.lang.Long]]) {
       DataTypes.createArrayType(LongType)
     } else if (t =:= typeOf[Array[Double]]) {
       DataTypes.createArrayType(DoubleType)
     } else if (t =:= typeOf[Option[Boolean]]) {
       BooleanType
-    } else {
+    } else if (t =:= typeOf[Boolean]) {
       BooleanType
+    } else {
+      throw new IllegalArgumentException(s"Cannot infer spark type for $t")
     }
   }
 }
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_functions.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_functions.scala
index b6b6caeae..ee2a371e7 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_functions.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/st_functions.scala
@@ -132,6 +132,22 @@ object st_functions extends DataFrameAPI {
   def ST_GeometryType(geometry: Column): Column = wrapExpression[ST_GeometryType](geometry)
   def ST_GeometryType(geometry: String): Column = wrapExpression[ST_GeometryType](geometry)
 
+  def ST_H3CellDistance(cell1: Column, cell2: Column): Column = wrapExpression[ST_H3CellDistance](cell1, cell2)
+
+  def ST_H3CellDistance(cell1: Long, cell2: Long): Column = wrapExpression[ST_H3CellDistance](cell1, cell2)
+  def ST_H3CellIDs(geometry: Column, level: Column, fullCover: Column): Column = wrapExpression[ST_H3CellIDs](geometry, level, fullCover)
+
+  def ST_H3CellIDs(geometry: String, level: Int, fullCover: Boolean): Column = wrapExpression[ST_H3CellIDs](geometry, level, fullCover)
+
+  def ST_H3KRing(cell: Column, k: Column, exactRing: Column): Column = wrapExpression[ST_H3KRing](cell, k, exactRing)
+  def ST_H3KRing(cell: Column, k: Integer, exactRing: Boolean): Column = wrapExpression[ST_H3KRing](cell, k, exactRing)
+
+  def ST_H3KRing(cell: Long, k: Integer, exactRing: Boolean): Column = wrapExpression[ST_H3KRing](cell, k, exactRing)
+
+  def ST_H3ToGeom(cellIds: Column): Column = wrapExpression[ST_H3ToGeom](cellIds)
+
+  def ST_H3ToGeom(cellIds: Array[Long]): Column = wrapExpression[ST_H3ToGeom](cellIds)
+
   def ST_InteriorRingN(polygon: Column, n: Column): Column = wrapExpression[ST_InteriorRingN](polygon, n)
   def ST_InteriorRingN(polygon: String, n: Int): Column = wrapExpression[ST_InteriorRingN](polygon, n)
 
diff --git a/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala b/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
index f691f62c2..0e5d094db 100644
--- a/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
+++ b/spark/common/src/test/scala/org/apache/sedona/sql/dataFrameAPITestScala.scala
@@ -18,19 +18,19 @@
  */
 package org.apache.sedona.sql
 
-import scala.collection.mutable.WrappedArray
 import org.apache.commons.codec.binary.Hex
-import org.apache.spark.sql.functions.{col, lit}
-import org.locationtech.jts.geom.Geometry
-import org.locationtech.jts.operation.buffer.BufferParameters
+import org.apache.spark.sql.functions.{col, element_at, lit}
+import org.apache.spark.sql.sedona_sql.expressions.st_aggregates._
 import org.apache.spark.sql.sedona_sql.expressions.st_constructors._
 import org.apache.spark.sql.sedona_sql.expressions.st_functions._
 import org.apache.spark.sql.sedona_sql.expressions.st_predicates._
-import org.apache.spark.sql.sedona_sql.expressions.st_aggregates._
 import org.junit.Assert.assertEquals
+import org.locationtech.jts.geom.{Geometry, Polygon}
 import org.locationtech.jts.io.WKTWriter
+import org.locationtech.jts.operation.buffer.BufferParameters
 
 import scala.collection.mutable
+import scala.collection.mutable.WrappedArray
 
 class dataFrameAPITestScala extends TestBaseScala {
 
@@ -176,12 +176,12 @@ class dataFrameAPITestScala extends TestBaseScala {
     }
 
     // functions
-      it("Passed ST_ConcaveHull"){
-        val baseDF = sparkSession.sql("SELECT ST_GeomFromWKT('Polygon ((0 0, 1 2, 2 2, 3 2, 5 0, 4 0, 3 1, 2 1, 1 0, 0 0))') as mline")
-        val df = baseDF.select(ST_ConcaveHull("mline", 1, true))
-        val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()
-        assert(actualResult == "POLYGON ((1 2, 2 2, 3 2, 5 0, 4 0, 1 0, 0 0, 1 2))")
-      }
+    it("Passed ST_ConcaveHull"){
+      val baseDF = sparkSession.sql("SELECT ST_GeomFromWKT('Polygon ((0 0, 1 2, 2 2, 3 2, 5 0, 4 0, 3 1, 2 1, 1 0, 0 0))') as mline")
+      val df = baseDF.select(ST_ConcaveHull("mline", 1, true))
+      val actualResult = df.take(1)(0).get(0).asInstanceOf[Geometry].toText()
+      assert(actualResult == "POLYGON ((1 2, 2 2, 3 2, 5 0, 4 0, 1 0, 0 0, 1 2))")
+    }
 
     it("Passed ST_ConvexHull") {
       val polygonDf = sparkSession.sql("SELECT ST_GeomFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 0))') AS geom")
@@ -962,6 +962,35 @@ class dataFrameAPITestScala extends TestBaseScala {
       assert (actualResult.subsetOf(mbrResult))
     }
 
+    it("Passed ST_H3CellIDs") {
+      val baseDF = sparkSession.sql("SELECT ST_GeomFromWKT('Polygon ((0 0, 1 2, 2 2, 3 2, 5 0, 4 0, 3 1, 2 1, 1 0, 0 0))') as geom")
+      val df = baseDF.select(ST_H3ToGeom(ST_H3CellIDs("geom", 6, true)))
+      val actualResult = df.take(1)(0).getAs[Geometry](0)
+      val targetShape = baseDF.take(1)(0).getAs[Polygon](0);
+      assert (actualResult.contains(targetShape))
+    }
+
+    it("Passed ST_H3CellDistance") {
+      val distance = sparkSession.sql("SELECT ST_Point(1.0, 2.0) lp, ST_Point(1.23, 1.59) rp")
+        .withColumn("lc", element_at(ST_H3CellIDs("lp", 8, true), 1))
+        .withColumn("rc", element_at(ST_H3CellIDs("rp", 8, true), 1))
+        .select(ST_H3CellDistance(col("lc"), col("rc")))
+        .collectAsList().get(0).get(0)
+      assert(78 == distance)
+    }
+
+    it("Passed ST_H3KRing") {
+      val neighborsAll = sparkSession.sql("SELECT ST_Point(1.0, 2.0) geom")
+        .withColumn("cell", element_at(ST_H3CellIDs("geom", 8, true), 1))
+        .select(ST_H3KRing(col("cell"), 3, false))
+        .collectAsList().get(0).get(0).asInstanceOf[mutable.WrappedArray[Long]]
+      val neighborsExactRing = sparkSession.sql("SELECT ST_Point(1.0, 2.0) geom")
+        .withColumn("cell", element_at(ST_H3CellIDs("geom", 8, true), 1))
+        .select(ST_H3KRing(col("cell"), 3, true))
+        .collectAsList().get(0).get(0).asInstanceOf[mutable.WrappedArray[Long]]
+      assert(neighborsExactRing.toSet.subsetOf(neighborsAll.toSet))
+    }
+
     it("Passed ST_DistanceSphere") {
       val baseDf = sparkSession.sql("SELECT ST_GeomFromWKT('POINT (0 0)') AS geom1, ST_GeomFromWKT('POINT (90 0)') AS geom2")
       var df = baseDf.select(ST_DistanceSphere("geom1", "geom2"))
diff --git a/spark/common/src/test/scala/org/apache/sedona/sql/functions/STH3Functions.scala b/spark/common/src/test/scala/org/apache/sedona/sql/functions/STH3Functions.scala
new file mode 100644
index 000000000..11d2ef9d0
--- /dev/null
+++ b/spark/common/src/test/scala/org/apache/sedona/sql/functions/STH3Functions.scala
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sedona.sql.functions
+
+import org.apache.sedona.common.Functions
+import org.apache.sedona.common.utils.H3Utils
+import org.apache.sedona.sql.{GeometrySample, TestBaseScala}
+import org.apache.spark.sql.functions.{col, expr, lit, monotonically_increasing_id}
+import org.locationtech.jts.geom.Coordinate
+import org.scalatest.{GivenWhenThen, Matchers}
+
+import scala.collection.mutable
+
+class STH3Functions extends TestBaseScala with Matchers with GeometrySample with GivenWhenThen {
+  import sparkSession.implicits._
+
+  describe("should pass ST_H3CellIDs"){
+
+    it("should return null while using ST_H3CellIDs when geometry is empty") {
+      val geometryTable = sparkSession.sparkContext.parallelize(1 to 10).toDF()
+        .withColumn("geom", lit(null))
+
+      When("using ST_MakePolygon on null geometries")
+      val geometryTableWithCellIDs = geometryTable
+        .withColumn("cell_ids", expr("ST_H3CellIDs(geom, 6, true)"))
+        .select("cell_ids").collect().filter(
+        r => r.get(0)!= null
+      )
+
+      Then("no exception should be raised")
+      require(geometryTableWithCellIDs.isEmpty)
+    }
+
+    it("should correctly return array of cell ids use of ST_H3CellIDs"){
+      Given("DataFrame with valid Geometries")
+      val geometryTable = Seq(
+        "POINT(1 2)",
+        "LINESTRING(-5 8, -6 1, -8 6, -2 5, -6 1, -5 8)",
+        "POLYGON ((75 29, 77 29, 76 28, 75 29))"
+
+      ).map(geom => Tuple1(wktReader.read(geom))).toDF("geom")
+
+      When("generate ST_H3CellIDs from those geometries")
+      val geometryDfWithCellIDs = geometryTable
+        .withColumn("cell_ids", expr("ST_H3CellIDs(geom, 6, true)"))
+
+      Then("valid should have list of Long type cell ids returned")
+      geometryDfWithCellIDs.select("cell_ids").collect().foreach(
+        r => require(r.get(0).isInstanceOf[mutable.WrappedArray[Long]] && r.size > 0)
+      )
+    }
+
+    it("use ST_H3CellIDs for spatial join") {
+      Given("DataFrame with valid line strings")
+      val polygonDf = sparkSession.read.format("csv").option("delimiter", "\t").option("header", "false").load(geojsonInputLocation)
+        .select(expr("ST_GeomFromGeoJSON(_c0)").as("countyshape"))
+        .select(
+        monotonically_increasing_id.as("id"),
+        col("countyshape").as("geom")
+      ).limit(100)
+      val rightPolygons = polygonDf.filter("id > 50")
+      rightPolygons.createOrReplaceTempView("rights")
+      // generate a sub list of polygons
+      val leftPolygons = polygonDf.filter("id <= 50")
+      leftPolygons.createOrReplaceTempView("lefts")
+      When("generate the cellIds for both set of polygons, and explode into separate rows, join them by cellIds")
+      val joinedDf = sparkSession.sql(
+        """
+          |with lcs as (
+          | select id, geom, explode(ST_H3CellIDs(geom, 8, true)) as cellId from lefts
+          |)
+          |, rcs as (
+          | select id, geom, explode(ST_H3CellIDs(geom, 8, true)) as cellId from rights
+          |)
+          |, join_res as (
+          | select lcs.id lid, rcs.id rid, first(lcs.geom) lgeom, first(rcs.geom) rgeom from lcs join rcs on lcs.cellId = rcs.cellId group by 1, 2
+          |)
+          |select sum(if(ST_Intersects(lgeom, rgeom), 1, 0)) count_true_positive, count(1) count_positive from join_res
+          |""".stripMargin
+      )
+      Then("the geoms joined by cell ids should all really intersect in this case." +
+        "Note that, cellIds equal doesn't necessarily mean the geoms intersect." +
+        "Sedona added augmentation to H3 native cover functions to ensure fully coverage, call ST_Intersects to filter out redundancy")
+      val res = joinedDf.collect()(0)
+      require(
+        res.get(0).asInstanceOf[Long] == 5
+      )
+      require(
+        res.get(0).asInstanceOf[Long] <= res.get(1).asInstanceOf[Long]
+      )
+    }
+
+    it("should correctly calculate the distance between two h3 cells") {
+      Given("DataFrame with valid Geometries")
+      val geometryTable = Seq(
+        Seq("POINT(1 2)", "POINT(1.23 1.59)")
+      ).map(geom => Tuple2(wktReader.read(geom(0)), wktReader.read(geom(1)))).toDF("lgeom", "rgeom")
+
+      Then("generate ST_H3CellIDs from those geometries")
+      val distance = geometryTable
+        .withColumn("lcell", expr("ST_H3CellIDs(lgeom, 8, true)[0]"))
+        .withColumn("rcell", expr("ST_H3CellIDs(rgeom, 8, true)[0]"))
+        .select(expr("ST_H3CellDistance(lcell, rcell)")).collectAsList().get(0).get(0)
+      val expects = Functions.h3CellDistance(
+        H3Utils.coordinateToCell(new Coordinate(1, 2), 8),
+        H3Utils.coordinateToCell(new Coordinate(1.23, 1.59), 8)
+      )
+      distance should equal (expects)
+    }
+
+    it("should correctly retrieve the KRing neighbors of given cellId") {
+      Given("DataFrame with valid Geometries")
+      val geometryTable = Seq(
+        "POINT(1 2)"
+      ).map(geom => Tuple1(wktReader.read(geom))).toDF("geom")
+
+      Then("generate ST_H3KRing from those geometries")
+      val exacts = geometryTable.select(
+        expr("ST_H3KRing(ST_H3CellIDs(geom, 8, true)[0], 3, true)")
+      ).collectAsList().get(0).get(0).asInstanceOf[mutable.WrappedArray[Long]].toArray
+      val expects = Functions.h3KRing(
+        H3Utils.coordinateToCell(new Coordinate(1, 2), 8),
+        3,
+        true
+      )
+      Then("the result of spark sql should match with direct common library call")
+      exacts should equal (expects)
+    }
+  }
+}