Skip to content

Commit

Permalink
PR comments and failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdunkerley committed Jun 7, 2024
1 parent 0b8e136 commit 266ea2d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import project.Errors.Illegal_Argument.Illegal_Argument
import project.Function.Function
import project.Meta
import project.Nothing.Nothing
import project.Panic.Panic
from project.Data.Boolean import Boolean, False, True
from project.Data.Filter_Condition.Filter_Condition import all
from project.Data.Text.Extensions import all
Expand Down Expand Up @@ -144,6 +145,12 @@ type Filter_Condition
will likely be faster than using the vector directly.
Is_In values:Vector|Any=[] action:Filter_Action=Filter_Action.Keep

## PRIVATE
Resolves a possibly auto-scoped Filter_Condition.
resolve_autoscoped filter:(Function|Filter_Condition) -> (Function|Filter_Condition) = case filter of
_ : Function -> Panic.catch Any (filter:Filter_Condition) _->filter
_ -> filter

## ICON convert
Converts a `Filter_Condition` condition into a predicate taking an
element and returning a value indicating whether the element should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ type Missing_Argument
## PRIVATE
Indicates that an expression cannot be evaluated because somewhere within
it, a function does not have all required arguments provided.
Error (argument_name : Text) (function_name : Text = "") (call_location : Source_Location | Nothing = Nothing)
Error (argument_name : Text) (function_name : Text | Nothing = Nothing) (call_location : Source_Location | Nothing = Nothing)

## PRIVATE
to_display_text : Text
to_display_text self = case self.function_name of
"" -> "Provide a value for the argument `" + self.argument_name + "`."
Nothing -> "Provide a value for the argument `" + self.argument_name + "`."
_ -> "Missing required argument `" + self.argument_name + "` in function `" + self.function_name + "`."

## PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,7 @@ type DB_Table
new_ctx = self.context.set_where_filters new_filters
self.updated_context new_ctx

filter_condition = case filter of
_ : Function -> Panic.catch Any (filter:Filter_Condition) _->filter
_ -> filter

filter_condition = Filter_Condition.resolve_autoscoped filter
case filter_condition of
_ : Filter_Condition ->
resolved = (self:Table_Ref).resolve_condition filter_condition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ resolve_aggregate table problem_builder aggregate_column:Aggregate_Column =
Value_Type.expect_text col <|
internal_column

result = case aggregate_column of
_ : Function -> resolve (aggregate_column:Aggregate_Column)
result = case aggregate_column:Aggregate_Column of
Group_By c as -> Group_By (resolve c) as
Count as -> Count as
Count_Distinct c as ignore_nothing -> if c == [] then Count as else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ type Join_Condition_Resolver
is_nothing column = case column of
Nothing -> True
_ -> False
conditions_vector = Vector.unify_vector_or_element conditions . map on_problems=No_Wrap condition->
case condition of
_ : Function -> (condition:Join_Condition)
_ -> condition
conditions_vector = Vector.unify_vector_or_element conditions . map on_problems=No_Wrap condition-> (condition:Join_Condition)
handle_equals left_selector right_selector =
left = resolve_left left_selector
right = resolve_right right_selector
Expand All @@ -59,7 +56,6 @@ type Join_Condition_Resolver
Join_Condition.Equals left_selector right_selector ->
right_resovled = if right_selector == "" then left_selector else right_selector
handle_equals left_selector right_resovled
column_name : Text -> handle_equals column_name column_name
Join_Condition.Equals_Ignore_Case left_selector right_selector locale ->
left = resolve_left left_selector
right_resovled = if right_selector == "" then left_selector else right_selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,7 @@ prepare_order_by internal_columns column_selectors problem_builder =
containing the original selector and the selected column.
resolve_order_by : Vector -> Text | Sort_Column | Vector (Text | Sort_Column) -> Problem_Builder -> Vector Column_Transform_Element
resolve_order_by internal_columns column_selectors problem_builder =
resolve_selector selector = case selector of
name : Text -> resolve_selector (Sort_Column.Name name)
ix : Integer -> resolve_selector (Sort_Column.Index ix)
resolve_selector selector:Sort_Column = case selector of
Sort_Column.Name name direction ->
resolve_selector (Sort_Column.Select_By_Name name direction Case_Sensitivity.Sensitive)
Sort_Column.Index ix _ ->
Expand All @@ -500,7 +498,6 @@ resolve_order_by internal_columns column_selectors problem_builder =
matches = match_columns name case_sensitivity internal_columns
if matches.is_empty then problem_builder.report_missing_input_columns [name]
matches.map c-> Column_Transform_Element.Value c selector
_ : Function -> resolve_selector (selector:Sort_Column)
Vector.unify_vector_or_element column_selectors . flat_map resolve_selector

## PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ type Join_Condition
- right_upper: A name or index of a column in the right table, used as
the upper bound for the check.
Between (left : Text | Integer = Missing_Argument.throw "left") (right_lower : Text | Integer = "") (right_upper : Text | Integer = "")

## PRIVATE
Join_Condition.from (that:Text) = Join_Condition.Equals that that
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ type Sort_Column
this selector. Their relative order between each other will be the same
as in the table.
Select_By_Name (name:Text|Regex=(Missing_Argument.throw "name")) direction:Sort_Direction=..Ascending case_sensitivity:Case_Sensitivity=..Insensitive

## PRIVATE
Sort_Column.from (that:Text) = Sort_Column.Name that

## PRIVATE
Sort_Column.from (that:Integer) = Sort_Column.Index that
6 changes: 1 addition & 5 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -1510,11 +1510,7 @@ type Table
filter self column (filter : Filter_Condition | (Any -> Boolean) = Filter_Condition.Equal True) on_problems:Problem_Behavior=..Report_Warning = case column of
_ : Column ->
mask filter_column = Table.Value (self.java_table.filter filter_column.java_column)

filter_condition = case filter of
_ : Function -> Panic.catch Any (filter:Filter_Condition) _->filter
_ -> filter

filter_condition = Filter_Condition.resolve_autoscoped filter
case filter_condition of
_ : Filter_Condition ->
resolved = (self:Table_Ref).resolve_condition filter_condition
Expand Down
7 changes: 4 additions & 3 deletions test/Base_Tests/src/Data/Vector_Spec.enso
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from Standard.Base import all
from Standard.Base.Data.Array_Proxy import Array_Proxy
import Standard.Base.Errors.Common.Missing_Argument
import Standard.Base.Errors.Empty_Error.Empty_Error
import Standard.Base.Data.Vector.Builder
import Standard.Base.Data.Vector.Map_Error
Expand Down Expand Up @@ -359,10 +360,10 @@ type_spec suite_builder name alter = suite_builder.group name group_builder->
v = alter [0, 1, 2]

r1 = v.filter Filter_Condition.Less
r1 . should_fail_with Illegal_Argument
r1.catch.to_display_text . should_contain "missing arguments"
r1 . should_fail_with Missing_Argument
r1.catch.to_display_text . should_contain "Provide a value for"

v.filter (Filter_Condition.Between 10) . should_fail_with Illegal_Argument
v.filter (Filter_Condition.Between 10) . should_fail_with Missing_Argument

group_builder.specify "should filter elements with indices" <|
(alter [0, 10, 2, 2] . filter_with_index (==)) . should_equal [0, 2]
Expand Down
2 changes: 1 addition & 1 deletion test/Base_Tests/src/Widget_Helpers_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_specs suite_builder =
group_builder.specify "make_regex_text_widget" <|
w = make_regex_text_widget
j = (Widgets.get_widget_json w) . to_text
j.should_contain "Option 'Leading_Whitespace' '..Leading_Whitespace' [] ''"
j.should_contain "Option 'Leading_Whitespace' 'Named_Pattern.Leading_Whitespace' [] ''"
group_builder.specify "make_data_cleanse_vector_selector" <|
w = make_data_cleanse_vector_selector
j = (Widgets.get_widget_json w) . to_text
Expand Down

0 comments on commit 266ea2d

Please sign in to comment.