Skip to content

Commit

Permalink
Fix snowflake sort tests (#11905)
Browse files Browse the repository at this point in the history
* Fix snowflake tests

* Rename flag to make code clearer

* Add new sort dialect flags

* Fix path for Snowflake
  • Loading branch information
AdRiley authored Dec 20, 2024
1 parent ddc2f3f commit e5a1c5a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion test/Table_Tests/src/Database/Upload_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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 <|
Expand Down
2 changes: 1 addition & 1 deletion test/Table_Tests/src/In_Memory/Common_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e5a1c5a

Please sign in to comment.