-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Refactor drop columns
to fix issues
#10903
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1e74651
Refactor arg handling
IanManske a08cb8a
Refactor drop column
IanManske 9a7e299
Refactor `ListStream` handling
IanManske 9129fec
Add comment
IanManske 247e1b1
Add tests
IanManske 3220a4e
Error on unsupported inputs
IanManske 65c97cd
Add record example
IanManske d95e3a8
Cleanup imports
IanManske 546f03a
Fix typo
IanManske 53b2d0b
Merge branch 'main' into drop-column-refactor
IanManske 56838c8
Use `Record::drain` and remove old comment
IanManske f9b2154
Merge branch 'main' into drop-column-refactor
IanManske a45cdd1
Use `Record::truncate`
IanManske 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 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 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 |
---|---|---|
|
@@ -93,3 +93,45 @@ fn fail_on_non_iterator() { | |
|
||
assert!(actual.err.contains("command doesn't support")); | ||
} | ||
|
||
#[test] | ||
fn disjoint_columns_first_row_becomes_empty() { | ||
let actual = nu!(pipeline( | ||
" | ||
[{a: 1}, {b: 2, c: 3}] | ||
| drop column | ||
| columns | ||
| to nuon | ||
" | ||
)); | ||
|
||
assert_eq!(actual.out, "[b, c]"); | ||
} | ||
|
||
#[test] | ||
fn disjoint_columns() { | ||
let actual = nu!(pipeline( | ||
" | ||
[{a: 1, b: 2}, {c: 3}] | ||
| drop column | ||
| columns | ||
| to nuon | ||
" | ||
)); | ||
Comment on lines
+98
to
+120
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. Gotta admit I find both of those behaviors absolutely cursed based on what the user sees with the default 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. Lol, I agree. Perhaps we could:
|
||
|
||
assert_eq!(actual.out, "[a, c]"); | ||
} | ||
|
||
#[test] | ||
fn record() { | ||
let actual = nu!("{a: 1, b: 2} | drop column | to nuon"); | ||
|
||
assert_eq!(actual.out, "{a: 1}"); | ||
} | ||
|
||
#[test] | ||
fn more_columns_than_record_has() { | ||
let actual = nu!("{a: 1, b: 2} | drop column 3 | to nuon"); | ||
|
||
assert_eq!(actual.out, "{}"); | ||
} |
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.
Thanks! Good catch!