From e5a1c5a6fa42f583521f2f322c0e1197e5491cf6 Mon Sep 17 00:00:00 2001 From: AdRiley Date: Fri, 20 Dec 2024 13:48:09 +0000 Subject: [PATCH] Fix snowflake sort tests (#11905) * Fix snowflake tests * Rename flag to make code clearer * Add new sort dialect flags * Fix path for Snowflake --- .../Database/Redshift/Internal/Redshift_Dialect.enso | 4 +++- .../Standard/Database/0.0.0-dev/src/Dialect_Flag.enso | 10 ++++++++-- .../src/Internal/Postgres/Postgres_Dialect.enso | 4 +++- .../0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso | 4 +++- .../0.0.0-dev/src/Internal/SQLServer_Dialect.enso | 4 +++- .../0.0.0-dev/src/Internal/Snowflake_Dialect.enso | 6 ++++-- .../src/Common_Table_Operations/Order_By_Spec.enso | 6 +++--- test/Table_Tests/src/Database/Upload_Spec.enso | 2 +- test/Table_Tests/src/In_Memory/Common_Spec.enso | 2 +- 9 files changed, 29 insertions(+), 13 deletions(-) diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso index 2a753d901a8d..4d7c649c1f9e 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso @@ -198,8 +198,10 @@ type Redshift_Dialect Dialect_Flag.Supports_Infinity -> True Dialect_Flag.Case_Sensitive_Text_Comparison -> True Dialect_Flag.Supports_Sort_Digits_As_Numbers -> False - Dialect_Flag.Case_Insensitive_Ordering -> False + Dialect_Flag.Supports_Case_Insensitive_Ordering -> False Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> True + Dialect_Flag.Order_By_Unicode_Normalization_When_Case_Insensitive -> True + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> True Dialect_Flag.Allows_Mixed_Type_Comparisons -> False Dialect_Flag.Supports_Unicode_Normalization -> False Dialect_Flag.NaN_Non_Comparable -> True diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Dialect_Flag.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Dialect_Flag.enso index 89f0e29ea453..6bd38ba440eb 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Dialect_Flag.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Dialect_Flag.enso @@ -34,10 +34,16 @@ type Dialect_Flag Supports_Sort_Digits_As_Numbers ## PRIAVTE Specifies if the backend supports case insensitive ordering. - Case_Insensitive_Ordering + Supports_Case_Insensitive_Ordering ## PRIVATE - Specifies if the backend supports unicode normalization in its default ordering. + Specifies if the backend uses case insensitive sort in its default ordering. + Case_Insensitive_Ordering_By_Default + ## PRIVATE + Specifies if the backend uses unicode normalization in its default ordering. Order_By_Unicode_Normalization_By_Default + ## PRIVATE + Specifies if the backend uses unicode normalization when doing case insentive ordering. + Order_By_Unicode_Normalization_When_Case_Insensitive ## PRIVATE Specifies if mixed operations comparing mixed types are allowed by a given backend. Some backends will allow diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso index 8ebd32a200e0..533712091822 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso @@ -270,8 +270,10 @@ type Postgres_Dialect Dialect_Flag.Supports_Infinity -> True Dialect_Flag.Case_Sensitive_Text_Comparison -> True Dialect_Flag.Supports_Sort_Digits_As_Numbers -> False - Dialect_Flag.Case_Insensitive_Ordering -> True + Dialect_Flag.Supports_Case_Insensitive_Ordering -> True Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> True + Dialect_Flag.Order_By_Unicode_Normalization_When_Case_Insensitive -> True + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> True Dialect_Flag.Allows_Mixed_Type_Comparisons -> False Dialect_Flag.Supports_Unicode_Normalization -> False Dialect_Flag.NaN_Non_Comparable -> False diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso index 9e0bcca0a1fb..efbc22421dc4 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso @@ -281,8 +281,10 @@ type SQLite_Dialect Dialect_Flag.Supports_Infinity -> True Dialect_Flag.Case_Sensitive_Text_Comparison -> True Dialect_Flag.Supports_Sort_Digits_As_Numbers -> False - Dialect_Flag.Case_Insensitive_Ordering -> False + Dialect_Flag.Supports_Case_Insensitive_Ordering -> True Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> False + Dialect_Flag.Order_By_Unicode_Normalization_When_Case_Insensitive -> False + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> False Dialect_Flag.Allows_Mixed_Type_Comparisons -> True Dialect_Flag.Supports_Unicode_Normalization -> False Dialect_Flag.NaN_Non_Comparable -> True diff --git a/distribution/lib/Standard/Microsoft/0.0.0-dev/src/Internal/SQLServer_Dialect.enso b/distribution/lib/Standard/Microsoft/0.0.0-dev/src/Internal/SQLServer_Dialect.enso index 781f2ce6e2bd..a681cc9fdeb1 100644 --- a/distribution/lib/Standard/Microsoft/0.0.0-dev/src/Internal/SQLServer_Dialect.enso +++ b/distribution/lib/Standard/Microsoft/0.0.0-dev/src/Internal/SQLServer_Dialect.enso @@ -259,8 +259,10 @@ type SQLServer_Dialect Dialect_Flag.Supports_Infinity -> False Dialect_Flag.Case_Sensitive_Text_Comparison -> False Dialect_Flag.Supports_Sort_Digits_As_Numbers -> False - Dialect_Flag.Case_Insensitive_Ordering -> True + Dialect_Flag.Supports_Case_Insensitive_Ordering -> True Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> True + Dialect_Flag.Order_By_Unicode_Normalization_When_Case_Insensitive -> True + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> True Dialect_Flag.Allows_Mixed_Type_Comparisons -> False Dialect_Flag.Supports_Unicode_Normalization -> False Dialect_Flag.NaN_Non_Comparable -> True diff --git a/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Dialect.enso b/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Dialect.enso index 3338d5262dfc..778a3609dcac 100644 --- a/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Dialect.enso +++ b/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Dialect.enso @@ -259,8 +259,10 @@ type Snowflake_Dialect Dialect_Flag.Supports_Infinity -> True Dialect_Flag.Case_Sensitive_Text_Comparison -> True Dialect_Flag.Supports_Sort_Digits_As_Numbers -> False - Dialect_Flag.Case_Insensitive_Ordering -> True - Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> True + Dialect_Flag.Supports_Case_Insensitive_Ordering -> True + Dialect_Flag.Order_By_Unicode_Normalization_By_Default -> False + Dialect_Flag.Order_By_Unicode_Normalization_When_Case_Insensitive -> True + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> False Dialect_Flag.Allows_Mixed_Type_Comparisons -> False Dialect_Flag.Supports_Unicode_Normalization -> False Dialect_Flag.NaN_Non_Comparable -> False diff --git a/test/Table_Tests/src/Common_Table_Operations/Order_By_Spec.enso b/test/Table_Tests/src/Common_Table_Operations/Order_By_Spec.enso index 8598078cfea8..b1e660caab8e 100644 --- a/test/Table_Tests/src/Common_Table_Operations/Order_By_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Operations/Order_By_Spec.enso @@ -267,9 +267,9 @@ add_order_specs suite_builder setup = t2.at "delta" . to_vector . should_equal ["a03", "a1", "a10", "a2"] t2.at "alpha" . to_vector . should_equal [0, 2, 3, 1] - if setup.flagged ..Case_Insensitive_Ordering then group_builder.specify "should support case insensitive ordering" <| + if setup.flagged ..Supports_Case_Insensitive_Ordering then group_builder.specify "should support case insensitive ordering" <| t1 = data.table.sort [..Name "eta"] text_ordering=(..Case_Insensitive) - expected = case setup.flagged ..Order_By_Unicode_Normalization_By_Default of + expected = case setup.flagged ..Order_By_Unicode_Normalization_When_Case_Insensitive of False -> ["Aleph", "alpha", "Beta", "bądź"] True -> ["Aleph", "alpha", "bądź", "Beta"] t1.at "eta" . to_vector . should_equal expected @@ -298,7 +298,7 @@ add_order_specs suite_builder setup = t3.at "psi" . to_vector . should_equal [Nothing, "c01", "c10", "C2"] t4 = data.table.sort [..Name "psi"] - case setup.flagged ..Case_Insensitive_Ordering of + case setup.flagged ..Case_Insensitive_Ordering_By_Default of True -> t4.at "psi" . to_vector . should_equal [Nothing, "c01", "c10", "C2"] False -> t4.at "psi" . to_vector . should_equal [Nothing, "C2", "c01", "c10"] diff --git a/test/Table_Tests/src/Database/Upload_Spec.enso b/test/Table_Tests/src/Database/Upload_Spec.enso index dce15a1d1fbb..e0d0f15a8fd2 100644 --- a/test/Table_Tests/src/Database/Upload_Spec.enso +++ b/test/Table_Tests/src/Database/Upload_Spec.enso @@ -242,7 +242,7 @@ add_specs suite_builder setup make_new_connection persistent_connector=True = group_builder.specify "should not issue a DELETE statement for the original table name in dry run mode, even if the table does not exist" <| original_table_name = Name_Generator.random_name "no-delete-test" - log_file = enso_project.data / "transient" / "sql.log" + log_file = (Project_Description.new enso_dev.Table_Tests).data / "transient" / "sql.log" log_file.delete_if_exists Test_Environment.unsafe_with_environment_override "ENSO_SQL_LOG_PATH" log_file.absolute.path <| Context.Output.with_disabled <| diff --git a/test/Table_Tests/src/In_Memory/Common_Spec.enso b/test/Table_Tests/src/In_Memory/Common_Spec.enso index a3b1eae0711a..9d30533f6314 100644 --- a/test/Table_Tests/src/In_Memory/Common_Spec.enso +++ b/test/Table_Tests/src/In_Memory/Common_Spec.enso @@ -41,7 +41,7 @@ in_memory_setup = True flagged_fn flag:Dialect_Flag = case flag of - Dialect_Flag.Case_Insensitive_Ordering -> False + Dialect_Flag.Case_Insensitive_Ordering_By_Default -> False Dialect_Flag.Removes_Trailing_Whitespace_Casting_From_Char_To_Varchar -> False _ -> True