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 e6e7c88bc8 [GH-2327] Add SedonaDB extra  (#2328)
e6e7c88bc8 is described below

commit e6e7c88bc8110bd10de36880ed8597313a3d8846
Author: Dewey Dunnington <[email protected]>
AuthorDate: Thu Sep 4 04:55:57 2025 +0000

    [GH-2327] Add SedonaDB extra  (#2328)
    
    * add extra
    
    * add stub module
    
    * add tests
    
    * remove python shared object
---
 python/sedona/db/__init__.py | 24 ++++++++++++++++++++++
 python/sedona/db/dbapi.py    | 22 +++++++++++++++++++++
 python/sedona/db/testing.py  | 25 +++++++++++++++++++++++
 python/setup.py              |  1 +
 python/tests/test_db.py      | 47 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 119 insertions(+)

diff --git a/python/sedona/db/__init__.py b/python/sedona/db/__init__.py
new file mode 100644
index 0000000000..569579f975
--- /dev/null
+++ b/python/sedona/db/__init__.py
@@ -0,0 +1,24 @@
+# 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.
+
+from sedonadb import connect, context, dataframe
+
+__all__ = [
+    "connect",
+    "context",
+    "dataframe",
+]
diff --git a/python/sedona/db/dbapi.py b/python/sedona/db/dbapi.py
new file mode 100644
index 0000000000..734f41e665
--- /dev/null
+++ b/python/sedona/db/dbapi.py
@@ -0,0 +1,22 @@
+# 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.
+
+from sedonadb.dbapi import connect
+
+__all__ = [
+    "connect",
+]
diff --git a/python/sedona/db/testing.py b/python/sedona/db/testing.py
new file mode 100644
index 0000000000..33718d7c9a
--- /dev/null
+++ b/python/sedona/db/testing.py
@@ -0,0 +1,25 @@
+# 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.
+
+from sedonadb.testing import DBEngine, DuckDB, PostGIS, SedonaDB
+
+__all__ = [
+    "DBEngine",
+    "DuckDB",
+    "SedonaDB",
+    "PostGIS",
+]
diff --git a/python/setup.py b/python/setup.py
index 15859e92bb..ef8a78b4bb 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -64,6 +64,7 @@ setup(
         "pydeck-map": ["geopandas", "pydeck==0.8.0"],
         "kepler-map": ["geopandas", "keplergl==0.3.2"],
         "flink": ["apache-flink>=1.19.0"],
+        "db": ["sedonadb[geopandas]"],
         "all": [
             "pyspark>=2.3.0",
             "geopandas",
diff --git a/python/tests/test_db.py b/python/tests/test_db.py
new file mode 100644
index 0000000000..42c4b608a1
--- /dev/null
+++ b/python/tests/test_db.py
@@ -0,0 +1,47 @@
+# 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.
+
+import pytest
+
+
+def test_sedonadb_connect():
+    pytest.importorskip("sedonadb")
+
+    import sedona.db
+
+    sd = sedona.db.connect()
+    assert sd.sql("SELECT 1 as one").count() == 1
+
+
+def test_sedonadb_dbapi():
+    pytest.importorskip("sedonadb")
+    pytest.importorskip("adbc_driver_manager")
+
+    import sedona.db.dbapi
+
+    with sedona.db.dbapi.connect() as con, con.cursor() as cur:
+        cur.execute("SELECT 1 as one")
+        assert cur.fetchall() == [(1,)]
+
+
+def test_sedonadb_testing():
+    pytest.importorskip("sedonadb")
+
+    from sedona.db.testing import SedonaDB
+
+    eng = SedonaDB()
+    eng.assert_query_result("SELECT 1 as one", "1")

Reply via email to