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

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


The following commit(s) were added to refs/heads/master by this push:
     new 77a9551f4 [SEDONA-545] Sedona Python DataFrame API fail due to missing 
commas (#1371)
77a9551f4 is described below

commit 77a9551f4ce90d65ee2d9b84f5f1cc1df8c1598c
Author: Jia Yu <[email protected]>
AuthorDate: Thu Apr 25 19:46:25 2024 -0700

    [SEDONA-545] Sedona Python DataFrame API fail due to missing commas (#1371)
    
    * Fix the bug
    
    * Fix a tiny issue
---
 python/sedona/spark/__init__.py        |   4 ++
 python/sedona/sql/st_aggregates.py     |  10 +--
 python/sedona/sql/st_constructors.py   |  24 ++-----
 python/sedona/sql/st_functions.py      | 125 ++-------------------------------
 python/sedona/sql/st_predicates.py     |  17 ++---
 python/tests/sql/test_dataframe_api.py |   5 ++
 6 files changed, 31 insertions(+), 154 deletions(-)

diff --git a/python/sedona/spark/__init__.py b/python/sedona/spark/__init__.py
index 7e80798a9..c98234a41 100644
--- a/python/sedona/spark/__init__.py
+++ b/python/sedona/spark/__init__.py
@@ -43,3 +43,7 @@ from sedona.spark.SedonaContext import SedonaContext
 from sedona.raster_utils.SedonaUtils import SedonaUtils
 from sedona.maps.SedonaKepler import SedonaKepler
 from sedona.maps.SedonaPyDeck import SedonaPyDeck
+from sedona.sql.st_aggregates import *
+from sedona.sql.st_constructors import *
+from sedona.sql.st_functions import *
+from sedona.sql.st_predicates import *
diff --git a/python/sedona/sql/st_aggregates.py 
b/python/sedona/sql/st_aggregates.py
index 4fca3985e..184ed38cf 100644
--- a/python/sedona/sql/st_aggregates.py
+++ b/python/sedona/sql/st_aggregates.py
@@ -14,6 +14,8 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
+import inspect
+import sys
 
 from functools import partial
 
@@ -23,11 +25,9 @@ from sedona.sql.dataframe_api import ColumnOrName, 
call_sedona_function, validat
 
 _call_aggregate_function = partial(call_sedona_function, "st_aggregates")
 
-__all__ = [
-    "ST_Envelope_Aggr",
-    "ST_Intersection_Aggr",
-    "ST_Union_Aggr",
-]
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+           if inspect.isfunction(obj)]
 
 
 @validate_argument_types
diff --git a/python/sedona/sql/st_constructors.py 
b/python/sedona/sql/st_constructors.py
index 4195a6fc9..aa7f2c976 100644
--- a/python/sedona/sql/st_constructors.py
+++ b/python/sedona/sql/st_constructors.py
@@ -14,6 +14,8 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
+import inspect
+import sys
 
 from functools import partial
 from typing import Optional, Union
@@ -23,25 +25,9 @@ from pyspark.sql import Column
 from sedona.sql.dataframe_api import ColumnOrName, ColumnOrNameOrNumber, 
call_sedona_function, validate_argument_types
 
 
-__all__ = [
-    "ST_GeomFromGeoHash",
-    "ST_GeomFromGeoJSON",
-    "ST_GeomFromGML",
-    "ST_GeomFromKML",
-    "ST_GeomFromText",
-    "ST_GeomFromWKB",
-    "ST_GeomFromWKT",
-    "ST_GeomFromEWKT",
-    "ST_LineFromText",
-    "ST_LineStringFromText",
-    "ST_Point",
-    "ST_PointFromText",
-    "ST_MakePoint"
-    "ST_PolygonFromEnvelope",
-    "ST_PolygonFromText",
-    "ST_MLineFromText",
-    "ST_MPolyFromText"
-]
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+           if inspect.isfunction(obj)]
 
 
 _call_constructor_function = partial(call_sedona_function, "st_constructors")
diff --git a/python/sedona/sql/st_functions.py 
b/python/sedona/sql/st_functions.py
index 3e9cb21f0..dfd9ae13c 100644
--- a/python/sedona/sql/st_functions.py
+++ b/python/sedona/sql/st_functions.py
@@ -14,6 +14,8 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
+import inspect
+import sys
 
 from functools import partial
 from typing import Optional, Union
@@ -23,123 +25,9 @@ from pyspark.sql import Column
 from sedona.sql.dataframe_api import call_sedona_function, ColumnOrName, 
ColumnOrNameOrNumber, validate_argument_types
 
 
-__all__ = [
-    "GeometryType",
-    "ST_3DDistance",
-    "ST_AddPoint",
-    "ST_Area",
-    "ST_AreaSpheroid",
-    "ST_AsBinary",
-    "ST_AsEWKB",
-    "ST_AsEWKT",
-    "ST_AsGeoJSON",
-    "ST_AsGML",
-    "ST_AsKML",
-    "ST_AsText",
-    "ST_Azimuth",
-    "ST_BestSRID",
-    "ST_Boundary",
-    "ST_Buffer",
-    "ST_BuildArea",
-    "ST_Centroid",
-    "ST_Collect",
-    "ST_CollectionExtract",
-    "ST_ClosestPoint",
-    "ST_ConcaveHull",
-    "ST_ConvexHull",
-    "ST_CrossesDateLine",
-    "ST_Difference",
-    "ST_Dimension",
-    "ST_Distance",
-    "ST_DistanceSphere",
-    "ST_DistanceSpheroid",
-    "ST_Dump",
-    "ST_DumpPoints",
-    "ST_EndPoint",
-    "ST_Envelope",
-    "ST_ExteriorRing",
-    "ST_FlipCoordinates",
-    "ST_Force_2D",
-    "ST_GeoHash",
-    "ST_GeometricMedian",
-    "ST_GeometryN",
-    "ST_GeometryType",
-    "ST_H3CellDistance",
-    "ST_H3CellIDs",
-    "ST_H3KRing",
-    "ST_H3ToGeom",
-    "ST_InteriorRingN",
-    "ST_Intersection",
-    "ST_IsClosed",
-    "ST_IsEmpty",
-    "ST_IsPolygonCW",
-    "ST_IsRing",
-    "ST_IsSimple",
-    "ST_IsValid",
-    "ST_IsValidReason",
-    "ST_Length",
-    "ST_LengthSpheroid",
-    "ST_LineFromMultiPoint",
-    "ST_LineInterpolatePoint",
-    "ST_LineLocatePoint",
-    "ST_LineMerge",
-    "ST_LineSubstring",
-    "ST_MakeLine",
-    "ST_Polygon"
-    "ST_Polygonize"
-    "ST_MakePolygon",
-    "ST_MakeValid",
-    "ST_MinimumBoundingCircle",
-    "ST_MinimumBoundingRadius",
-    "ST_Multi",
-    "ST_Normalize",
-    "ST_NPoints",
-    "ST_NDims",
-    "ST_NumGeometries",
-    "ST_NumInteriorRings",
-    "ST_PointN",
-    "ST_PointOnSurface",
-    "ST_ReducePrecision",
-    "ST_RemovePoint",
-    "ST_Reverse",
-    "ST_S2CellIDs",
-    "ST_S2ToGeom",
-    "ST_SetPoint",
-    "ST_SetSRID",
-    "ST_SRID",
-    "ST_Split",
-    "ST_StartPoint",
-    "ST_SubDivide",
-    "ST_SubDivideExplode",
-    "ST_SimplifyPreserveTopology",
-    "ST_SymDifference",
-    "ST_IsPolygonCCW",
-    "ST_ForcePolygonCCW",
-    "ST_Transform",
-    "ST_Union",
-    "ST_X",
-    "ST_XMax",
-    "ST_XMin",
-    "ST_Y",
-    "ST_YMax",
-    "ST_YMin",
-    "ST_Z",
-    "ST_ZMax",
-    "ST_ZMin",
-    "ST_NumPoints",
-    "ST_Force3D",
-    "ST_ForcePolygonCW",
-    "ST_NRings",
-    "ST_Translate",
-    "ST_VoronoiPolygons",
-    "ST_Angle",
-    "ST_Degrees",
-    "ST_FrechetDistance",
-    "ST_CoordDim",
-    "ST_IsCollection",
-    "ST_Affine",
-    "ST_BoundingDiagonal"
-]
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+           if inspect.isfunction(obj)]
 
 
 _call_st_function = partial(call_sedona_function, "st_functions")
@@ -1607,6 +1495,7 @@ def ST_VoronoiPolygons(geometry: ColumnOrName, tolerance: 
Optional[Union[ColumnO
     args = (geometry, tolerance, extendTo)
     return _call_st_function("ST_VoronoiPolygons", args)
 
+@validate_argument_types
 def ST_FrechetDistance(g1: ColumnOrName, g2: ColumnOrName) -> Column:
     """
     Computes discrete frechet distance between the two geometries.
@@ -1649,7 +1538,7 @@ def ST_Affine(geometry: ColumnOrName, a: 
Union[ColumnOrName, float], b: Union[Co
         args = (geometry, a, b, c, d, e, f, g, h, i, xOff, yOff, zOff)
     return _call_st_function("ST_Affine", args)
 
-
+@validate_argument_types
 def ST_BoundingDiagonal(geometry: ColumnOrName) -> Column:
     """
     Returns a LineString with the min/max values of each dimension of the 
bounding box of the given geometry as its
diff --git a/python/sedona/sql/st_predicates.py 
b/python/sedona/sql/st_predicates.py
index ee8d08678..5106e0473 100644
--- a/python/sedona/sql/st_predicates.py
+++ b/python/sedona/sql/st_predicates.py
@@ -14,6 +14,8 @@
 #  KIND, either express or implied.  See the License for the
 #  specific language governing permissions and limitations
 #  under the License.
+import inspect
+import sys
 
 from functools import partial
 
@@ -23,18 +25,9 @@ from typing import Union, Optional
 from sedona.sql.dataframe_api import ColumnOrName, call_sedona_function, 
validate_argument_types
 
 
-__all__ = [
-    "ST_Contains",
-    "ST_Crosses",
-    "ST_Disjoint",
-    "ST_Equals",
-    "ST_Intersects",
-    "ST_OrderingEquals",
-    "ST_Overlaps",
-    "ST_Touches",
-    "ST_Within",
-    "ST_DWithin"
-]
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+           if inspect.isfunction(obj)]
 
 
 _call_predicate_function = partial(call_sedona_function, "st_predicates")
diff --git a/python/tests/sql/test_dataframe_api.py 
b/python/tests/sql/test_dataframe_api.py
index ca319ab34..5bf79cc8a 100644
--- a/python/tests/sql/test_dataframe_api.py
+++ b/python/tests/sql/test_dataframe_api.py
@@ -21,6 +21,11 @@ from pyspark.sql import functions as f, Row
 import pytest
 from shapely.geometry.base import BaseGeometry
 
+from sedona.sql.st_aggregates import *
+from sedona.sql.st_constructors import *
+from sedona.sql.st_functions import *
+from sedona.sql.st_predicates import *
+
 from sedona.sql import (
     st_aggregates as sta,
     st_constructors as stc,

Reply via email to