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 a1bcdef84 [SEDONA-628] fix python st df function imports from
sedona.sql (#1529)
a1bcdef84 is described below
commit a1bcdef846d3f7b5838b4e1c91717cb880640e05
Author: James Willis <[email protected]>
AuthorDate: Thu Jul 25 13:54:33 2024 -0700
[SEDONA-628] fix python st df function imports from sedona.sql (#1529)
* [SEDONA-628] fix python st df function imports from sedona.sql
* add license information to new test file
---------
Co-authored-by: jameswillis <[email protected]>
---
python/sedona/sql/__init__.py | 22 ++++++++++++++++++++++
python/sedona/sql/st_aggregates.py | 9 +++++----
python/sedona/sql/st_constructors.py | 10 +++++-----
python/sedona/sql/st_functions.py | 10 +++++-----
python/sedona/sql/st_predicates.py | 10 +++++-----
.../sql/test_st_function_imports.py} | 19 +++++++++++++++++++
6 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/python/sedona/sql/__init__.py b/python/sedona/sql/__init__.py
index a67d5ea25..5211b7fd2 100644
--- a/python/sedona/sql/__init__.py
+++ b/python/sedona/sql/__init__.py
@@ -14,3 +14,25 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+import inspect
+import sys
+
+# These allow use to access the __all__
+import sedona.sql.st_aggregates as st_aggregates
+import sedona.sql.st_constructors as st_constructors
+import sedona.sql.st_functions as st_functions
+import sedona.sql.st_predicates as st_predicates
+
+# These bring the contents of the modules into this module
+from sedona.sql.st_aggregates import *
+from sedona.sql.st_constructors import *
+from sedona.sql.st_functions import *
+from sedona.sql.st_predicates import *
+
+__all__ = (
+ [name for name, obj in inspect.getmembers(sys.modules[__name__])] #
get expected values from the modules
+ + st_predicates.__all__
+ + st_constructors.__all__
+ + st_functions.__all__
+ + st_aggregates.__all__
+)
diff --git a/python/sedona/sql/st_aggregates.py
b/python/sedona/sql/st_aggregates.py
index 184ed38cf..67315ecf8 100644
--- a/python/sedona/sql/st_aggregates.py
+++ b/python/sedona/sql/st_aggregates.py
@@ -25,10 +25,6 @@ from sedona.sql.dataframe_api import ColumnOrName,
call_sedona_function, validat
_call_aggregate_function = partial(call_sedona_function, "st_aggregates")
-# Automatically populate __all__
-__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
- if inspect.isfunction(obj)]
-
@validate_argument_types
def ST_Envelope_Aggr(geometry: ColumnOrName) -> Column:
@@ -64,3 +60,8 @@ def ST_Union_Aggr(geometry: ColumnOrName) -> Column:
:rtype: Column
"""
return _call_aggregate_function("ST_Union_Aggr", geometry)
+
+
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+ if inspect.isfunction(obj)]
diff --git a/python/sedona/sql/st_constructors.py
b/python/sedona/sql/st_constructors.py
index 617722c2d..35403fbc7 100644
--- a/python/sedona/sql/st_constructors.py
+++ b/python/sedona/sql/st_constructors.py
@@ -25,11 +25,6 @@ from pyspark.sql import Column
from sedona.sql.dataframe_api import ColumnOrName, ColumnOrNameOrNumber,
call_sedona_function, validate_argument_types
-# 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")
@@ -454,3 +449,8 @@ def ST_GeomCollFromText(wkt: ColumnOrName, srid:
Optional[ColumnOrNameOrNumber]
args = (wkt) if srid is None else (wkt, srid)
return _call_constructor_function("ST_GeomCollFromText", args)
+
+
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+ if inspect.isfunction(obj)]
diff --git a/python/sedona/sql/st_functions.py
b/python/sedona/sql/st_functions.py
index 02fae8f24..1f98b0331 100644
--- a/python/sedona/sql/st_functions.py
+++ b/python/sedona/sql/st_functions.py
@@ -25,11 +25,6 @@ from pyspark.sql import Column
from sedona.sql.dataframe_api import call_sedona_function, ColumnOrName,
ColumnOrNameOrNumber, validate_argument_types
-# 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")
@validate_argument_types
@@ -2050,3 +2045,8 @@ def ST_Rotate(geometry: ColumnOrName, angle:
Union[ColumnOrName, float], originX
args = (geometry, angle)
return _call_st_function("ST_Rotate", args)
+
+
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+ if inspect.isfunction(obj)]
diff --git a/python/sedona/sql/st_predicates.py
b/python/sedona/sql/st_predicates.py
index 1969c8b5e..32efd7c5c 100644
--- a/python/sedona/sql/st_predicates.py
+++ b/python/sedona/sql/st_predicates.py
@@ -25,11 +25,6 @@ from typing import Union, Optional
from sedona.sql.dataframe_api import ColumnOrName, call_sedona_function,
validate_argument_types
-# 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")
@@ -227,3 +222,8 @@ def ST_DWithin(a: ColumnOrName, b: ColumnOrName, distance:
Union[ColumnOrName, f
"""
args = (a, b, distance, use_sphere) if use_sphere is not None else (a, b,
distance,)
return _call_predicate_function("ST_DWithin", args)
+
+
+# Automatically populate __all__
+__all__ = [name for name, obj in inspect.getmembers(sys.modules[__name__])
+ if inspect.isfunction(obj)]
diff --git a/python/sedona/sql/__init__.py
b/python/tests/sql/test_st_function_imports.py
similarity index 67%
copy from python/sedona/sql/__init__.py
copy to python/tests/sql/test_st_function_imports.py
index a67d5ea25..5ffb650ed 100644
--- a/python/sedona/sql/__init__.py
+++ b/python/tests/sql/test_st_function_imports.py
@@ -14,3 +14,22 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
+"""module without top level imports of these names"""
+
+from tests.test_base import TestBase
+
+
+class TestStFunctionImport(TestBase):
+ def test_import(self):
+ from sedona.sql import (
+ ST_Distance,
+ ST_Point,
+ ST_Contains,
+ ST_Envelope_Aggr,
+ )
+
+ ST_Distance
+ ST_Point
+ ST_Contains
+ ST_Envelope_Aggr