Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Yes, I have read the Contributor Rules and Contributor Development Guide
No, I haven't read it.
Is this PR related to a ticket?
Yes, and the PR name follows the format [SEDONA-XXX] my subject.
Yes, and the PR name follows the format [GH-2511] my subject. Closes #2511
No:
this is a documentation update. The PR name follows the format [DOCS] my subject
this is a CI update. The PR name follows the format [CI] my subject
What changes were proposed in this PR?
This PR adds a
to_sedonadb()
method to the SedonaSpark DataFrame. This method facilitates the conversion of a SedonaSpark DataFrame to a SedonaDB DataFrame, enabling users to leverage SedonaDB's capabilities for further spatial analysis and visualization (e.g., with lonboard).
The method:
Checks if sedona.db is installed and raises an informative ImportError if not.
Accepts an optional
connection
object. If not provided, it creates a new connection using sedona.db.connect().
Uses
dataframe_to_arrow()
to convert the data before creating the SedonaDB DataFrame.
How was this patch tested?
Added a new unit test file
python/tests/test_to_sedonadb.py
.
The tests use unittest.mock to simulate sedona.db (since it might not be present in the build environment) and verify that
connect()
and create_data_frame() are called correctly with the expected arguments.
Verified both cases: providing an existing connection and letting the method create a new one.
Did this PR include necessary documentation updates?
Yes, I am adding a new API. I am using the current SNAPSHOT version number in vX.Y.Z format.
Yes, I have updated the documentation.
No, this PR does not affect any public API so no need to change the documentation.