-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: DataFrame::select_columns and DataFrame::drop_columns for qualified duplicated field names
#18236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: DataFrame::select_columns and DataFrame::drop_columns for qualified duplicated field names
#18236
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ee783c0
add test
dqkqd b64b0b1
get all qualified fields for `drop_columns`
dqkqd 9ee9cae
use `test_table_with_name`
dqkqd 7d8c7c7
reorder
dqkqd 53ec5c7
try `select_columns`
dqkqd c4126d8
Merge remote-tracking branch 'public/main' into left-mark-drop-columns
dqkqd 9775df9
reorder tests
dqkqd defae36
clippy
dqkqd 77a0c7c
sort assert to avoid flaky
dqkqd f5045c7
Merge branch 'main' into left-mark-drop-columns
alamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -405,6 +405,55 @@ async fn select_with_periods() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn select_columns_duplicated_names_from_different_qualifiers() -> Result<()> { | ||
| let t1 = test_table_with_name("t1") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(0, Some(3))?; | ||
| let t2 = test_table_with_name("t2") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(3, Some(3))?; | ||
| let t3 = test_table_with_name("t3") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(6, Some(3))?; | ||
|
|
||
| let join_res = t1 | ||
| .join(t2, JoinType::Left, &["t1.c1"], &["t2.c1"], None)? | ||
| .join(t3, JoinType::Left, &["t1.c1"], &["t3.c1"], None)?; | ||
| assert_snapshot!( | ||
| batches_to_sort_string(&join_res.clone().collect().await.unwrap()), | ||
| @r" | ||
| +----+----+----+ | ||
| | c1 | c1 | c1 | | ||
| +----+----+----+ | ||
| | b | b | | | ||
| | b | b | | | ||
| | c | | | | ||
| | d | | d | | ||
| +----+----+----+ | ||
| " | ||
| ); | ||
|
|
||
| let select_res = join_res.select_columns(&["c1"])?; | ||
| assert_snapshot!( | ||
| batches_to_sort_string(&select_res.clone().collect().await.unwrap()), | ||
| @r" | ||
| +----+----+----+ | ||
| | c1 | c1 | c1 | | ||
| +----+----+----+ | ||
| | b | b | | | ||
| | b | b | | | ||
| | c | | | | ||
| | d | | d | | ||
| +----+----+----+ | ||
| " | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn drop_columns() -> Result<()> { | ||
| // build plan using Table API | ||
|
|
@@ -543,6 +592,54 @@ async fn drop_with_periods() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn drop_columns_duplicated_names_from_different_qualifiers() -> Result<()> { | ||
| let t1 = test_table_with_name("t1") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(0, Some(3))?; | ||
| let t2 = test_table_with_name("t2") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(3, Some(3))?; | ||
| let t3 = test_table_with_name("t3") | ||
| .await? | ||
| .select_columns(&["c1"])? | ||
| .limit(6, Some(3))?; | ||
|
|
||
| let join_res = t1 | ||
| .join(t2, JoinType::LeftMark, &["c1"], &["c1"], None)? | ||
| .join(t3, JoinType::LeftMark, &["c1"], &["c1"], None)?; | ||
| assert_snapshot!( | ||
| batches_to_sort_string(&join_res.clone().collect().await.unwrap()), | ||
| @r" | ||
| +----+-------+-------+ | ||
| | c1 | mark | mark | | ||
| +----+-------+-------+ | ||
| | b | true | false | | ||
| | c | false | false | | ||
| | d | false | true | | ||
| +----+-------+-------+ | ||
| " | ||
| ); | ||
|
|
||
| let drop_res = join_res.drop_columns(&["mark"])?; | ||
| assert_snapshot!( | ||
| batches_to_sort_string(&drop_res.clone().collect().await.unwrap()), | ||
| @r" | ||
| +----+ | ||
| | c1 | | ||
| +----+ | ||
| | b | | ||
| | c | | ||
| | d | | ||
| +----+ | ||
| " | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
Comment on lines
+626
to
+640
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This failed without the code changes |
||
|
|
||
| #[tokio::test] | ||
| async fn aggregate() -> Result<()> { | ||
| // build plan using DataFrame API | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line returned
SchemaErrorwithout the code changes.