Skip to content

Commit

Permalink
Imlpement By_Index
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jan 25, 2022
1 parent 46aaaaa commit 13001e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Missing_Input_Columns.to_display_text =

## One or more column indexes were invalid on the input table.
Can occur when using By_Index.
type Column_Indexes_Out_Of_Range (indexes : [Number])
type Column_Indexes_Out_Of_Range (indexes : [Integer])

Column_Indexes_Out_Of_Range.to_display_text : Text
Column_Indexes_Out_Of_Range.to_display_text = case this.indexes.length of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,24 @@ select_columns internal_columns selector reorder on_problems warnings =
result = Matching.match_criteria internal_columns names reorder=reorder name_mapper=(_.name) matching_strategy=matching_strategy on_problems=on_problems warnings=warnings
Warnings.map_warnings_and_errors promote_no_matches_to_missing_columns result
By_Index indices ->
# TODO partition indices into valid and invalid ones, so that we can report a warning or error
partitioned_indices = indices.partition (is_index_valid internal_columns)
good_indices = partitioned_indices.first
bad_indices = partitioned_indices.second
issues = if bad_indices.is_empty then [] else
[Column_Indexes_Out_Of_Range bad_indices]
result = case reorder of
True ->
here.select_indices_reordering internal_columns indices
False ->
here.select_indices_preserving_order internal_columns indices
# TODO warn if there are any non-unique columns in result?
result.distinct on=_.name
# TODO warn if there are any non-unique columns in result? TODO test cases to illustrate
Problem_Behavior_Module.attach_issues_as_needed (result.distinct on=_.name) on_problems issues warnings=warnings
By_Column columns ->
names = columns.map .name
result = Matching.match_criteria internal_columns names reorder=reorder name_mapper=(_.name) matching_strategy=(Matching.Exact case_sensitivity=True) on_problems=on_problems warnings=warnings
Warnings.map_warnings_and_errors promote_no_matches_to_missing_columns result

issues = if result.is_empty then [] else [No_Output_Columns]
issues = if result.is_empty then [No_Output_Columns] else []
Problem_Behavior_Module.attach_issues_as_needed result on_problems issues warnings=warnings

## PRIVATE
Expand Down

0 comments on commit 13001e1

Please sign in to comment.