feat(python/sedonadb): Ensure dataframes have meaningful default alias#935
Closed
paleolimbot wants to merge 7 commits into
Closed
feat(python/sedonadb): Ensure dataframes have meaningful default alias#935paleolimbot wants to merge 7 commits into
paleolimbot wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic, meaningful default aliases to Python DataFrames at creation time (especially for file-based reads), reducing ambiguous column reference errors in joins without requiring users to manually call .alias() in common cases.
Changes:
- Add
_ensure_aliased()+ default alias generation to automatically qualify DataFrame columns on creation. - Apply default aliasing to
Context.read_parquet(),Context.read_pyogrio(),Context.read_format(), andContext.sql(). - Add/adjust tests to assert alias behavior and relax a brittle explain-plan output assertion.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/sedonadb/python/sedonadb/dataframe.py | Introduces _ensure_aliased() and default-alias generation for newly created DataFrames. |
| python/sedonadb/python/sedonadb/context.py | Applies automatic aliasing to read helpers and sql(). |
| python/sedonadb/src/dataframe.rs | Special-cases aliasing for EXPLAIN logical plans to keep sd.sql("EXPLAIN ...") executable. |
| python/sedonadb/tests/test_dataframe.py | Updates tests around DataFrame creation from DataFrame and relaxes a brittle explain assertion. |
| python/sedonadb/tests/test_context.py | Removes the old test_read_parquet (now covered under io tests). |
| python/sedonadb/tests/io/test_parquet.py | Adds read_parquet alias assertions and keeps existing parquet behavior checks. |
| python/sedonadb/tests/io/test_pyogrio.py | Adds an alias assertion when reading a path via pyogrio. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
@jiayuasu Do you have bandwidth to review this one since it's mostly for joins? |
Member
|
Two things give me pause about this mechanism:
|
Member
Author
|
Got it...we can manually alias and/or add spatial join helpers later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR ensures all dataframes when created have a default alias that is probably unique and mostly meaningful (e.g., the filename being read). This ensures that joins don't require manual aliasing in most cases.
Motivating use case:
A downside here is that the explain plans get more verbose because they always print out the qualifier.
Closes #926.