From bc014b0357e7b56ea80692e512a3ba077dab4807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Wed, 12 Apr 2023 18:44:14 +0200 Subject: [PATCH] fix other in memory tests that I forgot about --- .../Table/0.0.0-dev/src/Data/Type/Value_Type.enso | 11 +++++++++-- .../src/Common_Table_Operations/Filter_Spec.enso | 2 +- .../src/Common_Table_Operations/Join/Join_Spec.enso | 2 +- test/Table_Tests/src/In_Memory/Table_Spec.enso | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type.enso index 340e5304a04a2..bc71494503e76 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Type/Value_Type.enso @@ -197,6 +197,9 @@ type Value_Type Value_Type.Date -> True Value_Type.Date_Time _ -> True Value_Type.Time -> True + ## Not all mixed types are ordered, but some can, so we allow ordering + for mixed columns. + Value_Type.Mixed -> True _ -> False ## PRIVATE @@ -204,12 +207,16 @@ type Value_Type are_comparable : Value_Type -> Value_Type -> Boolean are_comparable type_1 type_2 = find_bucket typ = - buckets = [["Integer", "Float", "Decimal"], ["Char"], ["Date"], ["Date_Time"], ["Time"]] + buckets = [["Integer", "Float", "Decimal"], ["Char"], ["Date"], ["Date_Time"], ["Time"], ["Mixed"]] ctor_name = Meta.meta typ . constructor . name buckets.index_of bucket-> bucket.contains ctor_name - find_bucket type_1 == find_bucket type_2 + bucket_1 = find_bucket type_1 + bucket_2 = find_bucket type_2 + if bucket_1.is_nothing || bucket_2.is_nothing then False else + if (type_1 == Value_Type.Mixed) || (type_2 == Value_Type.Mixed) then True else + bucket_1 == bucket_2 ## PRIVATE diff --git a/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso index 6d12acd301221..8e0d3eefa5d31 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Filter_Spec.enso @@ -163,7 +163,7 @@ spec setup = t = table_builder [["ix", [1, 2, 3, 4]], ["X", [Nothing, "A", "", " "]]] check_problem result = result.should_fail_with Invalid_Value_Type - result.catch.expected . should_equal Value_Type.Char + result.catch.expected . should_equal "Char" check_problem (t.filter "X" (Filter_Condition.Starts_With (t.at "ix"))) check_problem (t.filter "X" (Filter_Condition.Ends_With (t.at "ix"))) diff --git a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso index 7288eb388836d..716cc1e170c0b 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Join/Join_Spec.enso @@ -304,7 +304,7 @@ spec setup = test result = result.should_fail_with Invalid_Value_Type - result.catch.expected.should_equal Value_Type.Char + result.catch.expected.should_equal "Char" test <| t1.join t2 on=(Join_Condition.Equals_Ignore_Case "X" "W") on_problems=Problem_Behavior.Ignore diff --git a/test/Table_Tests/src/In_Memory/Table_Spec.enso b/test/Table_Tests/src/In_Memory/Table_Spec.enso index 5cd15769d3a2f..2e0faea54ab37 100644 --- a/test/Table_Tests/src/In_Memory/Table_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Table_Spec.enso @@ -881,7 +881,10 @@ spec = False -> True Nothing -> Nothing negated_column_vector = column_vector.map not - t = Table.new [["X", column_vector]] + ## A workaround to ensure that X has Boolean type. + It can be removed with + t0 = Table.new [["X", [True]+column_vector]] + t = t0.drop 1 in_column = Column.from_vector "in" in_vector expected_vector = column_vector.filter (Filter_Condition.Is_In in_vector)