diff --git a/test/Table_Tests/src/Aggregate_Spec.enso b/test/Table_Tests/src/Aggregate_Spec.enso index 3342d1fa0c3f9..173986b4e42af 100644 --- a/test/Table_Tests/src/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Aggregate_Spec.enso @@ -13,9 +13,7 @@ import Standard.Test.Problems polyglot java import java.lang.Double -type Test_Selection problem_handling=True advanced_stats=True text_concat=True text_shortest_longest=True first_last=True first_last_row_order=True std_dev=True multi_distinct=True aggregation_problems=True nan=True - -all_tests = Test_Selection True True True True True True True True True True +type Test_Selection problem_handling=True advanced_stats=True text_concat=True text_shortest_longest=True first_last=True first_last_row_order=True std_dev=True multi_distinct=True aggregation_problems=True nan=True date_support=True spec = table = (enso_project.data / "data.csv") . read @@ -39,7 +37,7 @@ spec = skip checks for backends which do not support particular features. - pending: An optional mark to disable all test groups. Can be used to indicate that some tests are disabled due to missing test setup. -aggregate_spec prefix table empty_table table_builder materialize is_database test_selection=all_tests pending=Nothing = +aggregate_spec prefix table empty_table table_builder materialize is_database test_selection=Test_Selection pending=Nothing = expect_column_names names table = table.columns . map .name . should_equal names frames_to_skip=2 @@ -1151,6 +1149,29 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te materialized.columns.at 0 . name . should_equal "B" materialized.columns.at 0 . to_vector . should_equal [2, 3, 2] + if test_selection.date_support then + Test.specify "should allow grouping by dates" <| + dates = ["Date", [Date.new 1997, Date.new 2000 2 2, Date.new 2022 12 31, Date.new 2000 2 2, Date.new 1997]] + times = ["Time", [Time_Of_Day.new, Time_Of_Day.new 0 0 0 500100900, Time_Of_Day.new 1 2 3, Time_Of_Day.new 0 0 0, Time_Of_Day.new 11 25 40]] + datetimes = ["DateTime", [Date_Time.new 1999, Date_Time.new 2022 8 29 17 28 5, Date_Time.new 1999 1 1 0 0 0, Date_Time.new 1998, Date_Time.new 1998]] + ints = ["Int", [1, 2, 4, 8, 16]] + table = table_builder [dates, times, datetimes, ints] + + g1 = table.aggregate [Group_By "Date", Sum "Int"] + m1 = materialize g1 . order_by (Sort_Column_Selector.By_Name ["Date"]) + m1.at "Date" . to_vector . should_equal [Date.new 1997, Date.new 2000 2 2, Date.new 2022 12 31] + m1.at "Sum Int" . to_vector . should_equal [17, 10, 4] + + g2 = table.aggregate [Group_By "Time", Sum "Int"] + m2 = materialize g2 . order_by (Sort_Column_Selector.By_Name ["Time"]) + m2.at "Time" . to_vector . should_equal [Time_Of_Day.new, Time_Of_Day.new 0 0 0 500100900, Time_Of_Day.new 1 2 3, Time_Of_Day.new 11 25 40] + m2.at "Sum Int" . to_vector . should_equal [9, 2, 4, 16] + + g3 = table.aggregate [Group_By "DateTime", Sum "Int"] + m3 = materialize g3 . order_by (Sort_Column_Selector.By_Name ["DateTime"]) + m3.at "DateTime" . to_vector . should_equal [Date_Time.new 1998, Date_Time.new 1999, Date_Time.new 2022 8 29 17 28 5] + m3.at "Sum Int" . to_vector . should_equal [24, 5, 2] + if test_selection.first_last && test_selection.first_last_row_order.not then Test.specify "should report a warning and ignore problematic columns if a feature is not supported" <| table = table_builder [["A", [1,2,Nothing,3]]] diff --git a/test/Table_Tests/src/Database/Postgres_Spec.enso b/test/Table_Tests/src/Database/Postgres_Spec.enso index c7482de314deb..408eac699f6cc 100644 --- a/test/Table_Tests/src/Database/Postgres_Spec.enso +++ b/test/Table_Tests/src/Database/Postgres_Spec.enso @@ -110,7 +110,7 @@ run_tests connection pending=Nothing = common_selection = Common_Table_Spec.Test_Selection supports_case_sensitive_columns=True order_by_unicode_normalization_by_default=True take_drop=False Common_Table_Spec.spec prefix table_builder test_selection=common_selection pending=pending - selection = Aggregate_Spec.Test_Selection first_last_row_order=False aggregation_problems=False + selection = Aggregate_Spec.Test_Selection first_last_row_order=False aggregation_problems=False date_support=False agg_in_memory_table = (enso_project.data / "data.csv") . read agg_table = connection.upload_table (Name_Generator.random_name "Agg1") agg_in_memory_table tables.append agg_table.name diff --git a/test/Table_Tests/src/Database/Redshift_Spec.enso b/test/Table_Tests/src/Database/Redshift_Spec.enso index c22a19b9da42a..477579f53ef9a 100644 --- a/test/Table_Tests/src/Database/Redshift_Spec.enso +++ b/test/Table_Tests/src/Database/Redshift_Spec.enso @@ -58,7 +58,7 @@ run_tests connection pending=Nothing = common_selection = Common_Table_Spec.Test_Selection supports_case_sensitive_columns=True order_by=False take_drop=False Common_Table_Spec.spec prefix table_builder test_selection=common_selection pending=pending - selection = Aggregate_Spec.Test_Selection text_concat=False text_shortest_longest=False first_last=False first_last_row_order=False multi_distinct=False aggregation_problems=False + selection = Aggregate_Spec.Test_Selection text_concat=False text_shortest_longest=False first_last=False first_last_row_order=False multi_distinct=False aggregation_problems=False date_support=False agg_in_memory_table = (enso_project.data / "data.csv") . read agg_table = connection.upload_table (Name_Generator.random_name "Agg1") agg_in_memory_table tables.append agg_table.name diff --git a/test/Table_Tests/src/Database/SQLite_Spec.enso b/test/Table_Tests/src/Database/SQLite_Spec.enso index b585c408fb0c5..4e0f654884950 100644 --- a/test/Table_Tests/src/Database/SQLite_Spec.enso +++ b/test/Table_Tests/src/Database/SQLite_Spec.enso @@ -70,7 +70,7 @@ sqlite_spec connection prefix = - creating complex nested queries using NTILE to compute the stats, - compiling SQLite library on our own and adding native extensions for the missing statistics. - selection = Aggregate_Spec.Test_Selection advanced_stats=False text_shortest_longest=False first_last=False first_last_row_order=False multi_distinct=False aggregation_problems=False nan=False + selection = Aggregate_Spec.Test_Selection advanced_stats=False text_shortest_longest=False first_last=False first_last_row_order=False multi_distinct=False aggregation_problems=False nan=False date_support=False agg_in_memory_table = (enso_project.data / "data.csv") . read agg_table = connection.upload_table (Name_Generator.random_name "Agg1") agg_in_memory_table empty_agg_table = connection.upload_table (Name_Generator.random_name "Agg_Empty") (agg_in_memory_table.take (First 0))