-
Notifications
You must be signed in to change notification settings - Fork 326
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
Allow parse to pass through already matched type. #12016
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2822b44
Fix the `return` dropdown for `read_many` on Excel.
jdunkerley 92418b3
Fix the `text_cleanse` widget by adding default for `remove` (a no-op).
jdunkerley b07d5ca
Allow parse to pass through the same type.
jdunkerley 5b78710
Fix Excel read_many dropdown properly
jdunkerley 33e2c28
Fix ALIAS.
jdunkerley c600051
Update parse on the column as well.
jdunkerley 34b0131
Fix `DB_Table.parse` mistake.
jdunkerley c67f3f2
Fix Column parse.
jdunkerley 6478c09
Reorder filter list.
jdunkerley 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
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
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
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
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 |
---|---|---|
|
@@ -557,37 +557,56 @@ add_conversion_specs suite_builder setup = | |
suite_builder.group prefix+"(Conversion_Spec) Simple variant of Table/Column.parse in all backends" group_builder-> | ||
group_builder.specify "should be able to parse simple integers" <| | ||
t = table_builder [["X", ["42", "0", "-1"]]] | ||
v = [42, 0, -1] | ||
|
||
c1 = t.at "X" . parse Value_Type.Integer | ||
setup.expect_integer_type c1 | ||
c1.to_vector . should_equal [42, 0, -1] | ||
c1.to_vector . should_equal v | ||
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. Is there a way to make sure the column was returned directly? 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. Perhaps we could do
|
||
|
||
c2 = t.parse ["X"] Value_Type.Integer . at "X" | ||
setup.expect_integer_type c2 | ||
c2.to_vector . should_equal [42, 0, -1] | ||
c2.to_vector . should_equal v | ||
|
||
t2 = table_builder [["X", v]] | ||
c3 = t2.parse ["X"] Value_Type.Integer . at "X" | ||
setup.expect_integer_type c3 | ||
c3.to_vector . should_equal v | ||
|
||
group_builder.specify "should be able to parse simple floats" <| | ||
t = table_builder [["X", ["42.5", "0.25", "-1.0"]]] | ||
v = [42.5, 0.25, -1.0] | ||
|
||
c1 = t.at "X" . parse Value_Type.Float | ||
c1.value_type.is_floating_point . should_be_true | ||
c1.to_vector . should_equal [42.5, 0.25, -1.0] | ||
c1.to_vector . should_equal v | ||
|
||
c2 = t.parse ["X"] Value_Type.Float . at "X" | ||
c2.value_type.is_floating_point . should_be_true | ||
c2.to_vector . should_equal [42.5, 0.25, -1.0] | ||
c2.to_vector . should_equal v | ||
|
||
t2 = table_builder [["X", v]] | ||
c3 = t2.parse ["X"] Value_Type.Float . at "X" | ||
c3.value_type.is_floating_point . should_be_true | ||
c3.to_vector . should_equal v | ||
|
||
if supports_dates then | ||
group_builder.specify "should be able to parse dates using a default format" <| | ||
t = table_builder [["X", ["2018-01-01", "2023-12-31"]]] | ||
v = [Date.new 2018 1 1, Date.new 2023 12 31] | ||
|
||
c1 = t.at "X" . parse Value_Type.Date | ||
c1.value_type.should_equal Value_Type.Date | ||
c1.to_vector . should_equal [Date.new 2018 1 1, Date.new 2023 12 31] | ||
c1.to_vector . should_equal v | ||
|
||
c2 = t.parse ["X"] Value_Type.Date . at "X" | ||
c2.value_type.should_equal Value_Type.Date | ||
c2.to_vector . should_equal [Date.new 2018 1 1, Date.new 2023 12 31] | ||
c2.to_vector . should_equal v | ||
|
||
t2 = table_builder [["X", v]] | ||
c3 = t2.parse ["X"] Value_Type.Date . at "X" | ||
c3.value_type.should_equal Value_Type.Date | ||
c3.to_vector . should_equal v | ||
|
||
if supports_dates.not then | ||
group_builder.specify "should report that date parsing is unsupported" <| | ||
t = table_builder [["X", ["2018-01-01", "2023-12-31"]]] | ||
|
@@ -600,14 +619,20 @@ add_conversion_specs suite_builder setup = | |
|
||
group_builder.specify "should be able to parse booleans with default format" <| | ||
t = table_builder [["X", ["true", "false", "true"]]] | ||
v = [True, False, True] | ||
|
||
c1 = t.at "X" . parse Value_Type.Boolean | ||
c1.value_type.should_equal Value_Type.Boolean | ||
c1.to_vector . should_equal [True, False, True] | ||
c1.to_vector . should_equal v | ||
|
||
c2 = t.parse ["X"] Value_Type.Boolean . at "X" | ||
c2.value_type.should_equal Value_Type.Boolean | ||
c2.to_vector . should_equal [True, False, True] | ||
c2.to_vector . should_equal v | ||
|
||
t2 = table_builder [["X", v]] | ||
c3 = t2.parse ["X"] Value_Type.Boolean . at "X" | ||
c3.value_type.should_equal Value_Type.Boolean | ||
c3.to_vector . should_equal v | ||
|
||
group_builder.specify "should report missing columns" <| | ||
t = table_builder [["X", ["42", "0", "-1"]]] | ||
|
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.
I've just realised that this check is redundant to the check in
Column.parse
.We could discard this change altogether and all should still work - because we will just call
parse
on all selected columns and for those of them that already fit the target type, they will be returned as-is and passed toset
-set
updating a column to the same column effectively does nothing.I think it could be a worthwhile simplification to remove this custom logic from
Table.parse
and only rely onColumn.parse
ensuring the correct behaviour. That way the logic is only in 2 places (because of alsoDB_Column
) instead of 4.