Skip to content

[GH-2511][Python] Add to_sedonadb() for SedonaSpark to SedonaDB conversion - #2515

Merged
jiayuasu merged 6 commits into
apache:masterfrom
Subham-KRLX:feat/to-sedonadb
Oct 20, 2026
Merged

jiayuasu merged 6 commits into
apache:masterfrom
Subham-KRLX:feat/to-sedonadb

Conversation

@Subham-KRLX

@Subham-KRLX Subham-KRLX commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

Is this PR related to a ticket?

Yes, this resolves GH-2511.
Closes #2511.

What changes were proposed in this PR?

This PR adds a to_sedonadb(connection=None) extension method to the pyspark.sql.DataFrame, enabling users to seamlessly convert a SedonaSpark DataFrame into a SedonaDB DataFrame using the GeoArrow format. The implementation supports passing a pre-existing connection or automatically creating one if not provided, while also providing a clear ImportError if sedona-db is not installed. By robustly leveraging the existing dataframe_to_arrow() utility, it ensures high-performance spatial data transfer between Spark-based big data workflows and specialized SedonaDB analytics.

How was this patch tested?

This patch was verified locally with a new automated test suite in python/tests/test_to_sedonadb.py that covers both automatic and manual connection management scenarios.

@Subham-KRLX

Copy link
Copy Markdown
Contributor Author

@jiayuasu please check this out.

@jbampton
jbampton marked this pull request as draft December 12, 2025 04:58
@jbampton jbampton self-assigned this Dec 12, 2025

@jbampton jbampton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is now marked as a draft.

Firstly your commit description is all messed up and not filled in correctly.

You also need a much better PR title that is more descriptive and you can edit that on the GitHub website there is a button for that.

And please don't mix different changes in one PR. For example you are editing the docs workflow YAML file and also adding Python code for another feature.

If you want your PRs to be reviewed and merged quickly you need to work harder and make it very easy for the committers

@Subham-KRLX
Subham-KRLX marked this pull request as ready for review December 12, 2025 13:37
@jbampton
jbampton self-requested a review March 12, 2026 00:04
@jbampton jbampton removed their assignment Mar 12, 2026
@Subham-KRLX Subham-KRLX changed the title Feat/to sedonadb [GH-2511][Python] Add to_sedonadb() method to SedonaSpark DataFrame Mar 25, 2026
@Subham-KRLX Subham-KRLX changed the title [GH-2511][Python] Add to_sedonadb() method to SedonaSpark DataFrame [GH-2511][Python] Add to_sedonadb() for SedonaSpark to SedonaDB conversion Mar 25, 2026
@Subham-KRLX

Copy link
Copy Markdown
Contributor Author

@jbampton Sorry for the delay I have been occupied with other tasks I have now fixed this correctly by rebasing it on upstream/master and removing all unrelated changes. I have also cleaned up the Python code and updated the description to be much more descriptive.

@jiayuasu
jiayuasu requested a review from Copilot March 26, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a DataFrame.to_sedonadb(connection=None) extension to convert SedonaSpark DataFrames into SedonaDB DataFrames via Arrow/GeoArrow, and introduces a Python test suite validating the conversion flow with/without a provided connection.

Changes:

  • Add to_sedonadb() monkey-patched method on pyspark.sql.DataFrame in sedona.spark.
  • Implement SedonaDB import + connection creation logic and Arrow handoff via dataframe_to_arrow().
  • Add unit tests covering automatic connection creation and using an explicit connection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
python/sedona/spark/init.py Adds to_sedonadb() extension method and wires it onto pyspark.sql.DataFrame.
python/tests/test_to_sedonadb.py Adds unit tests for conversion behavior with mocked SedonaDB and Arrow export.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/sedona/spark/__init__.py Resolved
Comment thread python/sedona/spark/__init__.py Resolved
Comment thread python/sedona/spark/__init__.py Resolved
Comment thread python/tests/test_to_sedonadb.py Resolved
Comment thread python/tests/test_to_sedonadb.py Resolved
@Subham-KRLX
Subham-KRLX marked this pull request as draft October 14, 2026 02:24
@Subham-KRLX
Subham-KRLX marked this pull request as ready for review October 20, 2026 05:28
@jiayuasu

Copy link
Copy Markdown
Member

[P2] Correct the dependency installation command

The missing-dependency error in python/sedona/spark/__init__.py:89 currently recommends pip install sedona-db, but that distribution does not exist. Users following the suggested command cannot install the missing dependency.

Please recommend the project's declared db extra instead:

pip install "apache-sedona[db]"

This extra installs sedonadb[geopandas]. Please update both the error message and the corresponding assertion in python/tests/test_to_sedonadb.py.

Verified locally: package resolution fails for sedona-db; the PR's three tests pass, and five additional integration checks pass with Spark 3.4.4 and SedonaDB 0.5.0.

@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Oct 20, 2026
@jiayuasu
jiayuasu merged commit 40976fb into apache:master Oct 20, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add to_sedonadb() method

4 participants