From a4c1b36fa2d21d7c4e72ad4b918235a814491303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Thu, 11 Aug 2022 20:54:32 +0200 Subject: [PATCH 1/7] Extend at, add length --- .../Database/0.0.0-dev/src/Data/Table.enso | 19 ++++++++----- .../Table/0.0.0-dev/src/Data/Table.enso | 27 +++++++++++++++---- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso index 4096b1849d60..8a55f67ac178 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso @@ -86,12 +86,19 @@ type Table Returns the column with the given name. Arguments: - - name: The name of the column to get. - at : Text -> Column ! No_Such_Column_Error - at self name = - candidates = self.internal_columns + self.context.meta_index - internal = candidates.find (p -> p.name == name) - self.make_column internal . map_error (_ -> No_Such_Column_Error name) + - selector: The name or index of the column to get. + at : Text | Integer -> Column ! No_Such_Column_Error | Index_Out_Of_Bounds_Error + at self selector = case selector of + Integer -> self.make_column (self.internal_columns.at selector) + Text -> + candidates = self.internal_columns + self.context.meta_index + internal_column = candidates.find (p -> p.name == name) + self.make_column internal_column . map_error (_ -> No_Such_Column_Error name) + + ## UNSTABLE + Returns the number of columns in the table. + length : Integer + length = self.internal_columns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index 52e95817938a..d65d6993c946 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -238,7 +238,7 @@ type Table ## Returns the column with the given name. Arguments: - - name: The name of the column being looked up. + - selector: The name or index of the column being looked up. > Example Get the names of all of the items from the shop inventory. @@ -246,10 +246,27 @@ type Table import Standard.Examples example_at = Examples.inventory_table.at "item_name" - at : Text -> Column ! No_Such_Column_Error - at self name = case self.java_table.getColumnOrIndexByName name of - Nothing -> Error.throw (No_Such_Column_Error name) - c -> Column.Column c + + > Example + Get the last column. + + import Standard.Examples + + example_at = Examples.inventory_table.at -1 + at : Text | Integer -> Column ! No_Such_Column_Error | Index_Out_Of_Bounds_Error + at self selector=0 = case selector of + Integer -> + java_columns = Vector.Vector self.java_table.getColumns + Column.Column (java_column.at selector) + Text -> + case self.java_table.getColumnOrIndexByName selector of + Nothing -> Error.throw (No_Such_Column_Error selector) + c -> Column.Column c + + ## UNSTABLE + Returns the number of columns in the table. + length : Integer + length = self.java_table.getColumns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be From 07648fe0f811b6884f8bf57c62e982bcc5cdb440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Thu, 11 Aug 2022 21:30:59 +0200 Subject: [PATCH 2/7] Add tests, checkpoint --- .../Database/0.0.0-dev/src/Data/Table.enso | 8 ++-- .../Table/0.0.0-dev/src/Data/Table.enso | 42 +------------------ .../Standard/Table/0.0.0-dev/src/Errors.enso | 26 ++++++++++++ .../Standard/Table/0.0.0-dev/src/Main.enso | 4 +- test/Table_Tests/src/Common_Table_Spec.enso | 26 ++++++++++++ .../src/Database/Codegen_Spec.enso | 3 +- 6 files changed, 62 insertions(+), 47 deletions(-) diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso index 8a55f67ac178..cb614bb34d72 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso @@ -16,7 +16,7 @@ import Standard.Table.Data.Aggregate_Column import Standard.Table.Internal.Aggregate_Column_Helper from Standard.Database.Data.Column import Column, Aggregate_Column_Builder from Standard.Database.Data.Internal.IR import Internal_Column -from Standard.Table.Data.Table import No_Such_Column_Error +from Standard.Table.Errors import No_Such_Column_Error from Standard.Table.Data.Column_Selector import Column_Selector, By_Index from Standard.Base.Data.Text.Text_Ordering import Text_Ordering from Standard.Table.Data.Data_Formatter import Data_Formatter @@ -88,12 +88,12 @@ type Table Arguments: - selector: The name or index of the column to get. at : Text | Integer -> Column ! No_Such_Column_Error | Index_Out_Of_Bounds_Error - at self selector = case selector of + at self selector=0 = case selector of Integer -> self.make_column (self.internal_columns.at selector) Text -> candidates = self.internal_columns + self.context.meta_index - internal_column = candidates.find (p -> p.name == name) - self.make_column internal_column . map_error (_ -> No_Such_Column_Error name) + internal_column = candidates.find (p -> p.name == selector) + self.make_column internal_column . map_error (_ -> No_Such_Column_Error selector) ## UNSTABLE Returns the number of columns in the table. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index d65d6993c946..c8ec220ce1dc 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -19,7 +19,7 @@ from Standard.Table.Data.Column_Type_Selection import Column_Type_Selection, Aut from Standard.Table.Data.Data_Formatter import Data_Formatter from Standard.Base.Data.Text.Text_Ordering import Text_Ordering from Standard.Base.Error.Problem_Behavior import Problem_Behavior, Report_Warning -from Standard.Table.Errors import Missing_Input_Columns, Column_Indexes_Out_Of_Range, Duplicate_Type_Selector +from Standard.Table.Errors import Missing_Input_Columns, Column_Indexes_Out_Of_Range, Duplicate_Type_Selector, No_Index_Set_Error, No_Such_Column_Error import Standard.Table.Data.Match_Columns import Standard.Table.Data.Column_Name_Mapping @@ -257,7 +257,7 @@ type Table at self selector=0 = case selector of Integer -> java_columns = Vector.Vector self.java_table.getColumns - Column.Column (java_column.at selector) + Column.Column (java_columns.at selector) Text -> case self.java_table.getColumnOrIndexByName selector of Nothing -> Error.throw (No_Such_Column_Error selector) @@ -890,17 +890,6 @@ type Table row_count : Integer row_count self = self.java_table.rowCount - ## Returns the number of rows in this table. - - > Example - Count the number of rows in the table. - - import Standard.Examples - - example_length = Examples.inventory_table.length - length : Integer - length self = self.row_count - ## Returns a Table describing this table's contents. The table lists all columns, counts of non-null items and storage types @@ -1138,33 +1127,6 @@ type Table to_csv : Text to_csv self = Text.from self (File_Format.Delimited delimiter=",") - -## UNSTABLE - - An error returned when a non-existent column is being looked up. - - Arguments: - - column_name: The name of the column that doesn't exist. -type No_Such_Column_Error column_name - -## UNSTABLE - - Create a human-readable version of the no such column error. -No_Such_Column_Error.to_display_text : Text -No_Such_Column_Error.to_display_text self = - "The column " + self.column_name + " does not exist." - -## UNSTABLE - - An error returned when getting an index but no index is set for that table. -type No_Index_Set_Error - -## UNSTABLE - - Create a human-readable version of the no such column error. -No_Index_Set_Error.to_display_text : Text -No_Index_Set_Error.to_display_text self = "The table does not have an index set." - ## UNSTABLE An error returned when the table contains no rows. diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso index c83cc23aa2c7..5198a5008f9f 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Errors.enso @@ -219,3 +219,29 @@ Column_Name_Mismatch.handle_java_exception = cause = caught_panic.payload.cause Error.throw (Column_Name_Mismatch (Vector.Vector cause.getMissing) (Vector.Vector cause.getExtras) cause.getMessage) Panic.catch ColumnNameMismatchException handler=throw_column_name_mismatch + +## UNSTABLE + + An error returned when a non-existent column is being looked up. + + Arguments: + - column_name: The name of the column that doesn't exist. +type No_Such_Column_Error column_name + +## UNSTABLE + + Create a human-readable version of the no such column error. +No_Such_Column_Error.to_display_text : Text +No_Such_Column_Error.to_display_text self = + "The column " + self.column_name + " does not exist." + +## UNSTABLE + + An error returned when getting an index but no index is set for that table. +type No_Index_Set_Error + +## UNSTABLE + + Create a human-readable version of the no such column error. +No_Index_Set_Error.to_display_text : Text +No_Index_Set_Error.to_display_text self = "The table does not have an index set." diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Main.enso index 063f0e95eade..c2e9a03e9df2 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Main.enso @@ -4,6 +4,7 @@ import Standard.Geo.Geo_Json import Standard.Table.IO.File_Read import Standard.Table.IO.File_Format import Standard.Table.IO.Excel +import Standard.Table.Errors import Standard.Table.Data.Table import Standard.Table.Data.Column @@ -13,7 +14,8 @@ export Standard.Table.Data.Column export Standard.Table.IO.File_Read export Standard.Table.IO.File_Format -from Standard.Table.Data.Table export new, from_rows, join, concat, No_Such_Column_Error, Table +from Standard.Table.Data.Table export new, from_rows, join, concat, Table +from Standard.Table.Errors export No_Such_Column_Error ## ALIAS To Table diff --git a/test/Table_Tests/src/Common_Table_Spec.enso b/test/Table_Tests/src/Common_Table_Spec.enso index 4c602ff119b1..375966584471 100644 --- a/test/Table_Tests/src/Common_Table_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Spec.enso @@ -47,6 +47,32 @@ spec prefix table_builder test_selection pending=Nothing = expect_column_names names table = table.columns . map .name . should_equal names frames_to_skip=2 + Test.group prefix+"Table.at" pending=pending <| + Test.specify "should allow selecting columns by name" <| + column_1 = table.at "bar" + column_1.name . should_equal "bar" + column_1.to_vector . should_equal [4, 5, 6] + + table.at "nonexistent column name" . should_fail_with No_Such_Column_Error + Test.specify "should allow selecting columns by index" <| + column_1 = table.at + column_1.name . should_equal "foo" + column_1.to_vector . should_equal [1, 2, 3] + + column_2 = table.at 2 + column_2.name . should_equal "Baz" + column_2.to_vector . should_equal [7, 8, 9] + + column_3 = table.at -1 + column_3.name . should_equal "abcd123" + column_3.to_vector . should_equal [19, 20, 21] + + table.at 100 . should_fail_with Index_Out_Of_Bounds_Error + + Test.group prefix+"Table.length" pending=pending <| + Test.specify "should allow getting the column count" <| + table.length . should_equal 7 + Test.group prefix+"Table.select_columns" pending=pending <| Test.specify "should work as shown in the doc examples" <| expect_column_names ["foo", "bar"] <| table.select_columns (By_Name ["bar", "foo"]) diff --git a/test/Table_Tests/src/Database/Codegen_Spec.enso b/test/Table_Tests/src/Database/Codegen_Spec.enso index 463136cbcb75..0987b590bf41 100644 --- a/test/Table_Tests/src/Database/Codegen_Spec.enso +++ b/test/Table_Tests/src/Database/Codegen_Spec.enso @@ -4,8 +4,7 @@ from Standard.Table.Data.Column_Selector as Column_Selector_Module import By_Nam import Standard.Table.Data.Sort_Column_Selector import Standard.Table.Data.Sort_Column from Standard.Table.Data.Aggregate_Column import all -from Standard.Table import No_Such_Column_Error -from Standard.Table.Errors as Table_Errors import No_Input_Columns_Selected, Missing_Input_Columns +from Standard.Table.Errors as Table_Errors import No_Input_Columns_Selected, Missing_Input_Columns, No_Such_Column_Error from Standard.Database import all from Standard.Database.Data.Sql import Sql_Type From c99f5fa707fb8a34e256dd94aa99fcb0f83d430d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Thu, 11 Aug 2022 22:10:38 +0200 Subject: [PATCH 3/7] fixes --- .../Database/0.0.0-dev/src/Data/Table.enso | 8 +++--- .../Table/0.0.0-dev/src/Data/Table.enso | 2 +- .../lib/Standard/Test/0.0.0-dev/src/Main.enso | 2 +- test/Table_Tests/src/Excel_Spec.enso | 28 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso index cb614bb34d72..12145a25d36d 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso @@ -92,13 +92,13 @@ type Table Integer -> self.make_column (self.internal_columns.at selector) Text -> candidates = self.internal_columns + self.context.meta_index - internal_column = candidates.find (p -> p.name == selector) - self.make_column internal_column . map_error (_ -> No_Such_Column_Error selector) + internal_column = candidates.find (p -> p.name == selector) . map_error (_ -> No_Such_Column_Error selector) + self.make_column internal_column ## UNSTABLE Returns the number of columns in the table. length : Integer - length = self.internal_columns.length + length self = self.internal_columns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be @@ -430,7 +430,7 @@ type Table - index: The column to use as the index of the table. set_index : Text | Column | Vector Text -> Table set_index self index = Panic.recover Any <| - new_index = (Helpers.unify_vector_singleton index).map (self.at >> .as_internal) + new_index = (Helpers.unify_vector_singleton index).map ((self.at _) >> .as_internal) new_ctx = self.context.set_index new_index new_cols = self.internal_columns.filter col-> turned_into_index = new_index.exists i-> i.name == col.name diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index c8ec220ce1dc..ec5705720c9a 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -266,7 +266,7 @@ type Table ## UNSTABLE Returns the number of columns in the table. length : Integer - length = self.java_table.getColumns.length + length self = self.java_table.getColumns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso index f8432f8c9ddb..3357f8d017e1 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso @@ -743,7 +743,7 @@ fail_match_on_unexpected_error error frames_to_skip = payload = error.catch loc = Meta.get_source_location 1+frames_to_skip msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + loc + ")." - fail msg + fail msg+'\n'+error.get_stack_trace_text ## PRIVATE diff --git a/test/Table_Tests/src/Excel_Spec.enso b/test/Table_Tests/src/Excel_Spec.enso index 5f6a35b666b6..85636320ce47 100644 --- a/test/Table_Tests/src/Excel_Spec.enso +++ b/test/Table_Tests/src/Excel_Spec.enso @@ -518,24 +518,24 @@ spec = table = xlsx_sheet.read (File_Format.Excel (Sheet 1)) check_table table - table_2 = xlsx_sheet.read (File_Format.Excel (Sheet 1 (table.length - col_a.length))) - table_2.length . should_equal col_a.length + table_2 = xlsx_sheet.read (File_Format.Excel (Sheet 1 (table.row_count - col_a.length))) + table_2.row_count . should_equal col_a.length check_table <| table_2 Test.specify "should let you read by sheet name" <| table = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1")) check_table table - table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length))) - table_2.length . should_equal col_a.length + table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length))) + table_2.row_count . should_equal col_a.length check_table <| table_2 Test.specify "should let you read XLS by sheet index" <| table = xls_sheet.read (File_Format.Excel (Sheet 1)) check_table table - table_2 = xls_sheet.read (File_Format.Excel (Sheet 1 (table.length - col_a.length))) - table_2.length . should_equal col_a.length + table_2 = xls_sheet.read (File_Format.Excel (Sheet 1 (table.row_count - col_a.length))) + table_2.row_count . should_equal col_a.length check_table <| table_2 Test.specify "should let you read XLS by sheet name" <| @@ -546,8 +546,8 @@ spec = table = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C")) check_table table - table_2 = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C" (table.length - col_a.length))) - table_2.length . should_equal col_a.length + table_2 = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C" (table.row_count - col_a.length))) + table_2.row_count . should_equal col_a.length check_table <| table_2 check_table <| xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!10:13")) @@ -555,22 +555,22 @@ spec = Test.specify "should let you read by range name" <| table = xlsx_sheet.read (File_Format.Excel (Cell_Range "myData")) - table.length . should_equal col_a.length + table.row_count . should_equal col_a.length check_table <| table Test.specify "should let you restrict number of rows read and skip rows" <| table = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1")) check_table table - table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length))) - table_2.length . should_equal col_a.length + table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length))) + table_2.row_count . should_equal col_a.length check_table <| table_2 - table_3 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length) 2)) - table_3.length . should_equal 2 + table_3 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length) 2)) + table_3.row_count . should_equal 2 table_4 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" row_limit=6)) - table_4.length . should_equal 6 + table_4.row_count . should_equal 6 Test.group "Problems" <| Test.specify "should handle non-existing file gracefully" <| From 331ff067937261ca93e71c876e5304f9de372a13 Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Thu, 18 Aug 2022 10:19:46 +0100 Subject: [PATCH 4/7] Remove `length` from the Table as causes confusion. Replaced with `column_count`. --- .../lib/Standard/Database/0.0.0-dev/src/Data/Table.enso | 7 +++---- .../lib/Standard/Table/0.0.0-dev/src/Data/Table.enso | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso index 12145a25d36d..50aadad52b99 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso @@ -95,10 +95,9 @@ type Table internal_column = candidates.find (p -> p.name == selector) . map_error (_ -> No_Such_Column_Error selector) self.make_column internal_column - ## UNSTABLE - Returns the number of columns in the table. - length : Integer - length self = self.internal_columns.length + ## Returns the number of columns in the table. + column_count : Integer + column_count self = self.internal_columns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index ec5705720c9a..1be88ce3dfff 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -263,10 +263,9 @@ type Table Nothing -> Error.throw (No_Such_Column_Error selector) c -> Column.Column c - ## UNSTABLE - Returns the number of columns in the table. - length : Integer - length self = self.java_table.getColumns.length + ## Returns the number of columns in the table. + column_count : Integer + column_count self = self.java_table.getColumns.length ## Returns a new table with a chosen subset of columns, as specified by the `columns`, from the input table. Any unmatched input columns will be From 987bd3cc72d983252d76c1a6006f9c4fe730f441 Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Thu, 18 Aug 2022 10:52:51 +0100 Subject: [PATCH 5/7] CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7ef5e5f7f0..fe97fc964ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -173,6 +173,8 @@ `Text.drop`.][3617] - [Updated `Vector.take` and `Vector.drop` and removed their obsolete counterparts.][3629] +- [Expanded `Table.at` to support index access and added `Table.column_count` + method.][3644] [debug-shortcuts]: https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug @@ -273,6 +275,7 @@ [3601]: https://github.com/enso-org/enso/pull/3601 [3617]: https://github.com/enso-org/enso/pull/3617 [3629]: https://github.com/enso-org/enso/pull/3629 +[3644]: https://github.com/enso-org/enso/pull/3644 #### Enso Compiler From fb773820c333e4d41a3e96e0e0f6db5b8f82d53c Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Thu, 18 Aug 2022 11:16:25 +0100 Subject: [PATCH 6/7] Trailing space. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85822a1c0ba4..185aa7fe515b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -178,7 +178,7 @@ counterparts.][3629] - [Short-hand syntax for `order_by` added.][3643] - [Expanded `Table.at` to support index access and added `Table.column_count` - method.][3644] + method.][3644] [debug-shortcuts]: https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug From 8f62c014263169bd1b6b0b85d9b95e215dc870af Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Thu, 18 Aug 2022 12:42:35 +0100 Subject: [PATCH 7/7] Use column_count where possible. Fix on mis-use of length. --- .../Table/0.0.0-dev/src/Data/Table.enso | 2 +- test/Table_Tests/src/Aggregate_Spec.enso | 196 +++++++++--------- test/Table_Tests/src/Common_Table_Spec.enso | 4 +- .../src/Database/Codegen_Spec.enso | 2 +- .../Table_Tests/src/Database/Common_Spec.enso | 6 +- .../src/Database/Postgres_Spec.enso | 2 +- test/Table_Tests/src/Excel_Spec.enso | 10 +- test/Table_Tests/src/Table_Date_Spec.enso | 2 +- test/Table_Tests/src/Table_Spec.enso | 4 +- 9 files changed, 114 insertions(+), 114 deletions(-) diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso index 3f582d79b996..5662ad9ac20d 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Data/Table.enso @@ -511,7 +511,7 @@ type Table Nothing -> Nothing _ -> val.to_text new_names = self.columns.map mapper - self.take_end (self.length - 1) . rename_columns (Column_Name_Mapping.By_Position new_names) on_problems=on_problems + self.take_end (self.row_count - 1) . rename_columns (Column_Name_Mapping.By_Position new_names) on_problems=on_problems ## ALIAS group, summarize diff --git a/test/Table_Tests/src/Aggregate_Spec.enso b/test/Table_Tests/src/Aggregate_Spec.enso index 514e679fc66d..9312a49c2fe0 100644 --- a/test/Table_Tests/src/Aggregate_Spec.enso +++ b/test/Table_Tests/src/Aggregate_Spec.enso @@ -59,7 +59,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Count Nothing] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Count" materialized.columns.at 0 . at 0 . should_equal 2500 @@ -67,7 +67,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Count_Nothing "Hexadecimal", Count_Not_Nothing "Hexadecimal", Count_Empty "TextWithNothing", Count_Not_Empty "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Count Nothing Hexadecimal" materialized.columns.at 0 . at 0 . should_equal 236 materialized.columns.at 1 . name . should_equal "Count Not Nothing Hexadecimal" @@ -81,7 +81,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Count_Distinct "Code", Count_Distinct "Index", Count_Distinct "Flag"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Count Distinct Code" materialized.columns.at 0 . at 0 . should_equal 2333 materialized.columns.at 1 . name . should_equal "Count Distinct Index" @@ -93,7 +93,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Count_Distinct (By_Name ["Index", "Flag"])] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Count Distinct Index Flag" materialized.columns.at 0 . at 0 . should_equal 20 @@ -101,7 +101,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Sum "Value", Sum "ValueWithNothing", Average "Value", Average "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Sum Value" materialized.columns.at 0 . at 0 . should_equal -932.411550 epsilon=0.000001 materialized.columns.at 1 . name . should_equal "Sum ValueWithNothing" @@ -115,7 +115,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Standard_Deviation "Value", Standard_Deviation "ValueWithNothing", (Standard_Deviation "Value" population=True), (Standard_Deviation "ValueWithNothing" population=True)] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Standard Deviation Value" materialized.columns.at 0 . at 0 . should_equal 56.708660 epsilon=0.000001 materialized.columns.at 1 . name . should_equal "Standard Deviation ValueWithNothing" @@ -129,7 +129,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Median "Index", Median "Value", Median "ValueWithNothing", Mode "Index", Percentile 0.25 "Value", Percentile 0.40 "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 6 + materialized.column_count . should_equal 6 materialized.columns.at 0 . name . should_equal "Median Index" materialized.columns.at 0 . at 0 . should_equal 5 epsilon=0.000001 materialized.columns.at 1 . name . should_equal "Median Value" @@ -147,7 +147,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [First "Index" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Hexadecimal", Sort_Column.Name "TextWithNothing"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value"])] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "First Index" materialized.columns.at 0 . at 0 . should_equal 5 materialized.columns.at 1 . name . should_equal "Last ValueWithNothing" @@ -157,7 +157,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending, Sort_Column.Name "Code"]), First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Code", Sort_Column.Name "Value" Sort_Direction.Descending]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending])] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "First TextWithNothing" materialized.columns.at 0 . at 0 . should_equal "riwaiqq1io" materialized.columns.at 1 . name . should_equal "First TextWithNothing_1" @@ -169,7 +169,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [First "Index", Last "Value"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "First Index" materialized.columns.at 0 . at 0 . should_equal 7 materialized.columns.at 1 . name . should_equal "Last Value" @@ -179,7 +179,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Minimum "Value", Maximum "Value", Minimum "ValueWithNothing", Maximum "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Minimum Value" materialized.columns.at 0 . at 0 . should_equal -99.964200 epsilon=0.000001 materialized.columns.at 1 . name . should_equal "Maximum Value" @@ -193,7 +193,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Shortest "TextWithNothing", Longest "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Shortest TextWithNothing" materialized.columns.at 0 . at 0 . should_equal "f5" materialized.columns.at 1 . name . should_equal "Longest TextWithNothing" @@ -203,7 +203,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Concatenate "Code"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate Code" materialized.columns.at 0 . at 0 . length . should_equal 7500 @@ -212,7 +212,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Count Nothing] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Count" materialized.columns.at 0 . at 0 . should_equal 0 @@ -220,7 +220,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Count_Nothing "Hexadecimal", Count_Not_Nothing "Hexadecimal", Count_Empty "TextWithNothing", Count_Not_Empty "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Count Nothing Hexadecimal" materialized.columns.at 0 . at 0 . should_equal 0 materialized.columns.at 1 . name . should_equal "Count Not Nothing Hexadecimal" @@ -234,7 +234,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Count_Distinct "Code" (ignore_nothing=False), Count_Distinct "Code" (ignore_nothing=True)] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Count Distinct Code" materialized.columns.at 0 . at 0 . should_equal 0 materialized.columns.at 1 . name . should_equal "Count Distinct Code_1" @@ -244,7 +244,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Sum "Value", Average "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Sum Value" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Average ValueWithNothing" @@ -254,7 +254,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Standard_Deviation "Value", (Standard_Deviation "ValueWithNothing" population=True)] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Standard Deviation Value" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Standard Deviation ValueWithNothing" @@ -264,7 +264,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Median "Index", Mode "Index", Percentile 0.25 "Value"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Median Index" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Mode Index" @@ -276,7 +276,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [First "Index" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Hexadecimal", Sort_Column.Name "TextWithNothing"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value"])] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "First Index" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Last ValueWithNothing" @@ -286,7 +286,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [First "Index", Last "Value"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "First Index" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Last Value" @@ -296,7 +296,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Minimum "Value", Maximum "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Minimum Value" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Maximum ValueWithNothing" @@ -306,7 +306,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Shortest "TextWithNothing", Longest "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Shortest TextWithNothing" materialized.columns.at 0 . at 0 . should_equal Nothing materialized.columns.at 1 . name . should_equal "Longest TextWithNothing" @@ -316,7 +316,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Concatenate "Code"] materialized = materialize grouped grouped.row_count . should_equal 1 - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate Code" materialized.columns.at 0 . at 0 . should_equal Nothing @@ -325,7 +325,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Count Nothing] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Count" @@ -333,7 +333,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Count_Nothing "Hexadecimal", Count_Not_Nothing "Hexadecimal", Count_Empty "TextWithNothing", Count_Not_Empty "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Count Nothing Hexadecimal" materialized.columns.at 2 . name . should_equal "Count Not Nothing Hexadecimal" @@ -344,7 +344,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Count_Distinct "Code"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Count Distinct Code" @@ -352,7 +352,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Sum "Value", Average "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Sum Value" materialized.columns.at 2 . name . should_equal "Average ValueWithNothing" @@ -361,7 +361,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Standard_Deviation "Value", (Standard_Deviation "ValueWithNothing" population=True)] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Standard Deviation Value" materialized.columns.at 2 . name . should_equal "Standard Deviation ValueWithNothing" @@ -370,7 +370,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Median "Index", Mode "Index", Percentile 0.25 "Value"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Median Index" materialized.columns.at 2 . name . should_equal "Mode Index" @@ -380,7 +380,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, First "Index" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Hexadecimal", Sort_Column.Name "TextWithNothing"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value"])] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "First Index" materialized.columns.at 2 . name . should_equal "Last ValueWithNothing" @@ -389,7 +389,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, First "Index", Last "Value"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "First Index" materialized.columns.at 2 . name . should_equal "Last Value" @@ -398,7 +398,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Minimum "Value", Maximum "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Minimum Value" materialized.columns.at 2 . name . should_equal "Maximum ValueWithNothing" @@ -407,7 +407,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Shortest "TextWithNothing", Longest "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Shortest TextWithNothing" materialized.columns.at 2 . name . should_equal "Longest TextWithNothing" @@ -416,7 +416,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = empty_table.aggregate [Group_By 0, Concatenate "Code"] materialized = materialize grouped grouped.row_count . should_equal 0 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Code" materialized.columns.at 1 . name . should_equal "Concatenate Code" @@ -425,7 +425,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count Nothing] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -436,7 +436,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count_Nothing "Hexadecimal", Count_Not_Nothing "Hexadecimal", Count_Empty "TextWithNothing", Count_Not_Empty "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -453,7 +453,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count_Distinct "Code", Count_Distinct "Index", Count_Distinct "Flag"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -468,7 +468,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count_Distinct (By_Name ["Index", "Flag"])] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -479,7 +479,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Sum "Value", Sum "ValueWithNothing", Average "Value", Average "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -496,7 +496,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Standard_Deviation "Value", Standard_Deviation "ValueWithNothing", (Standard_Deviation "Value" population=True), (Standard_Deviation "ValueWithNothing" population=True)] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -513,7 +513,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Median "Index", Median "Value", Median "ValueWithNothing", Mode "Index", Percentile 0.25 "Value", Percentile 0.40 "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 7 + materialized.column_count . should_equal 7 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -534,7 +534,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value", Sort_Column.Name "Flag"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value"])] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [7] materialized idx.is_nothing . should_be_false @@ -547,7 +547,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending, Sort_Column.Name "Flag"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending])] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [7] materialized idx.is_nothing . should_be_false @@ -560,7 +560,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", First "TextWithNothing", Last "Value"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -573,7 +573,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Minimum "Value", Maximum "Value", Minimum "ValueWithNothing", Maximum "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -590,7 +590,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Shortest "TextWithNothing", Longest "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [1] materialized idx.is_nothing . should_be_false @@ -603,7 +603,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Concatenate "Code"] materialized = materialize grouped grouped.row_count . should_equal 10 - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Index" idx = find_row [6] materialized idx.is_nothing . should_be_false @@ -615,7 +615,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Flag", Count Nothing, Group_By "Index"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Flag" materialized.columns.at 2 . name . should_equal "Index" idx = find_row [False, 6] materialized [0, 2] @@ -627,7 +627,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Count_Nothing "Hexadecimal", Count_Not_Nothing "Hexadecimal", Group_By "Index", Count_Empty "TextWithNothing", Group_By "Flag", Count_Not_Empty "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 6 + materialized.column_count . should_equal 6 materialized.columns.at 4 . name . should_equal "Flag" materialized.columns.at 2 . name . should_equal "Index" idx = find_row [False, 6] materialized [4, 2] @@ -645,7 +645,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count_Distinct "Code", Count_Distinct "Index", Count_Distinct "Flag", Group_By "Flag"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 5 + materialized.column_count . should_equal 5 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 4 . name . should_equal "Flag" idx = find_row [False, 6] materialized [4, 0] @@ -661,7 +661,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Count_Distinct (By_Name ["Index", "Flag"]), Group_By "Flag"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 2 . name . should_equal "Flag" idx = find_row [False, 6] materialized [2, 0] @@ -673,7 +673,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Sum "Value", Sum "ValueWithNothing", Average "Value", Average "ValueWithNothing", Group_By "Flag"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 6 + materialized.column_count . should_equal 6 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 5 . name . should_equal "Flag" idx = find_row [False, 6] materialized [5, 0] @@ -691,7 +691,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Group_By "Flag", Standard_Deviation "Value", Standard_Deviation "ValueWithNothing", (Standard_Deviation "Value" population=True), (Standard_Deviation "ValueWithNothing" population=True)] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 6 + materialized.column_count . should_equal 6 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 1 . name . should_equal "Flag" idx = find_row [False, 6] materialized [1, 0] @@ -709,7 +709,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Median "Index", Median "Value", Median "ValueWithNothing", Mode "Index", Group_By "Index", Group_By "Flag", Percentile 0.25 "Value", Percentile 0.40 "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 8 + materialized.column_count . should_equal 8 materialized.columns.at 5 . name . should_equal "Flag" materialized.columns.at 4 . name . should_equal "Index" idx = find_row [False, 6] materialized [5, 4] @@ -731,7 +731,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Flag", First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value", Sort_Column.Name "Flag"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value"]), Group_By "Index"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Flag" materialized.columns.at 3 . name . should_equal "Index" idx = find_row [False, 7] materialized [0, 3] @@ -745,7 +745,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Flag", First "TextWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending, Sort_Column.Name "Flag"]), Last "ValueWithNothing" (order_by = Sort_Column_Selector.By_Name [Sort_Column.Name "Value" Sort_Direction.Descending]), Group_By "Index"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Flag" materialized.columns.at 3 . name . should_equal "Index" idx = find_row [True, 7] materialized [0, 3] @@ -759,7 +759,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Flag", First "TextWithNothing", Last "Value", Group_By "Index"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Flag" materialized.columns.at 3 . name . should_equal "Index" idx = find_row [False, 6] materialized [0, 3] @@ -773,7 +773,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Minimum "Value", Maximum "Value", Group_By "Flag", Minimum "ValueWithNothing", Maximum "ValueWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 6 + materialized.column_count . should_equal 6 materialized.columns.at 3 . name . should_equal "Flag" materialized.columns.at 0 . name . should_equal "Index" idx = find_row [False, 6] materialized [3, 0] @@ -791,7 +791,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Group_By "Flag", Shortest "TextWithNothing", Longest "TextWithNothing"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 4 + materialized.column_count . should_equal 4 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 1 . name . should_equal "Flag" idx = find_row [1, False] materialized @@ -805,7 +805,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "Index", Group_By "Flag", Concatenate "Code"] materialized = materialize grouped grouped.row_count . should_equal 20 - materialized.columns.length . should_equal 3 + materialized.column_count . should_equal 3 materialized.columns.at 0 . name . should_equal "Index" materialized.columns.at 1 . name . should_equal "Flag" idx = find_row [6, False] materialized @@ -819,7 +819,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [Shortest "A", Shortest "B"] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "Shortest A" materialized.columns.at 0 . to_vector . should_equal [""] materialized.columns.at 1 . name . should_equal "Shortest B" @@ -831,7 +831,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [Group_By "A", (Concatenate "B" prefix="[[" suffix="]]" separator="; ")] result.row_count . should_equal 2 materialized = materialize result . order_by (Sort_Column_Selector.By_Name [Sort_Column.Name "A"]) - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 0 . name . should_equal "A" materialized.columns.at 0 . to_vector . should_equal ["bar", "foo"] materialized.columns.at 1 . name . should_equal "Concatenate B" @@ -842,7 +842,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [(Concatenate "A" prefix="[[" suffix="]]" separator="," quote_char="'")] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate A" materialized.columns.at 0 . to_vector . should_equal ["[['1,0',b,'''c','''''',',']]"] @@ -851,7 +851,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [(Concatenate "A" prefix="[[" suffix="]]" separator="," quote_char="'")] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate A" materialized.columns.at 0 . to_vector . should_equal ["[['1,0',A,'','',B,,,C]]"] @@ -860,7 +860,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [(Concatenate "A" prefix="[[" suffix="]]" separator=",")] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate A" materialized.columns.at 0 . to_vector . should_equal ["[[1,0,A,,,B,,,C]]"] @@ -869,7 +869,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [(Concatenate "A")] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate A" materialized.columns.at 0 . to_vector . should_equal ["1,0ABC"] @@ -878,7 +878,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te result = table.aggregate [(Concatenate "A" quote_char="'")] result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.at 0 . name . should_equal "Concatenate A" materialized.columns.at 0 . to_vector . should_equal ["'1''0'A''''BC"] @@ -911,14 +911,14 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t5.aggregate [Group_By "G", Count_Distinct "A" (ignore_nothing=True)] r1.row_count . should_equal 2 m1 = materialize r1 . order_by (Sort_Column_Selector.By_Name [Sort_Column.Name "G"]) - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 m1.columns.first.to_vector . should_equal ["bar", "foo"] m1.columns.second.to_vector . should_equal [0, 1] r2 = t5.aggregate [Group_By "G", Count_Distinct "A" (ignore_nothing=False)] r2.row_count . should_equal 2 m2 = materialize r2 . order_by (Sort_Column_Selector.By_Name [Sort_Column.Name "G"]) - m2.columns.length . should_equal 2 + m2.column_count . should_equal 2 m2.columns.first.to_vector . should_equal ["bar", "foo"] m2.columns.second.to_vector . should_equal [1, 2] @@ -928,14 +928,14 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r2 = table.aggregate [Count_Distinct (By_Name ["A", "B"]) (ignore_nothing=False)] r2.row_count.should_equal 1 m2 = materialize r2 - m2.columns.length.should_equal 1 + m2.column_count.should_equal 1 m2.columns.first.name . should_equal "Count Distinct A B" m2.columns.first.to_vector . should_equal [4] r1 = table.aggregate [Count_Distinct (By_Name ["A", "B"]) (ignore_nothing=True)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length.should_equal 1 + m1.column_count.should_equal 1 m1.columns.first.name . should_equal "Count Distinct A B" m1.columns.first.to_vector . should_equal [3] @@ -944,7 +944,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = table_builder [["X", [1]]] . aggregate [Standard_Deviation "X" (population=False), Standard_Deviation "X" (population=True)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 m1.columns.first.at 0 . should_equal Nothing m1.columns.second.at 0 . should_equal 0 @@ -954,13 +954,13 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = table.aggregate [Average "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.at 0 . should_equal (2/3) epsilon=0.00001 r2 = table.aggregate [Group_By "G", Average "X"] r2.row_count.should_equal 2 m2 = materialize r2 . order_by (Sort_Column_Selector.By_Name [Sort_Column.Name "G"]) - m2.columns.length . should_equal 2 + m2.column_count . should_equal 2 m2.columns.first.to_vector . should_equal ["a", "b"] m2.columns.second.to_vector . should_equal [0.5, 1] @@ -969,7 +969,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = table.aggregate [Median "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.to_vector . should_equal [0.5] Test.specify "widening to decimals on Percentile" (pending = resolve_pending test_selection.advanced_stats) <| @@ -977,7 +977,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = table.aggregate [Percentile 0.3 "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.to_vector . should_equal [2.5] Test.specify "widening to decimals on Standard_Deviation" (pending = resolve_pending test_selection.std_dev) <| @@ -985,7 +985,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = table.aggregate [Standard_Deviation "X" (population=True), Standard_Deviation "X" (population=False)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 m1.columns.first.at 0 . should_equal 1.1180339887499 epsilon=0.000001 m1.columns.second.at 0 . should_equal 1.2909944487358 epsilon=0.000001 @@ -1006,14 +1006,14 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Average "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.at 0 . should_equal pos_inf t2 = table_builder [["X", [Nothing, pos_inf, neg_inf, 0]]] r2 = t2.aggregate [Average "X"] r2.row_count.should_equal 1 m2 = materialize r2 - m2.columns.length . should_equal 1 + m2.column_count . should_equal 1 expect_null_or_nan <| m2.columns.first.at 0 Test.specify "on Median" (pending = resolve_pending test_selection.advanced_stats) <| @@ -1021,28 +1021,28 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Median "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.at 0 . should_equal pos_inf t2 = table_builder [["X", [pos_inf, pos_inf, neg_inf, neg_inf]]] r2 = t2.aggregate [Median "X"] r2.row_count.should_equal 1 m2 = materialize r2 - m2.columns.length . should_equal 1 + m2.column_count . should_equal 1 expect_null_or_nan <| m2.columns.first.at 0 t3 = table_builder [["X", [pos_inf, pos_inf, Nothing, 0, 10, 20, neg_inf, neg_inf]]] r3 = t3.aggregate [Median "X"] r3.row_count.should_equal 1 m3 = materialize r3 - m3.columns.length . should_equal 1 + m3.column_count . should_equal 1 m3.columns.first.at 0 . should_equal 10 t4 = table_builder [["X", [Nothing, pos_inf, pos_inf, 10, 12]]] r4 = t4.aggregate [Median "X"] r4.row_count.should_equal 1 m4 = materialize r4 - m4.columns.length . should_equal 1 + m4.column_count . should_equal 1 m4.columns.first.at 0 . should_equal pos_inf Test.specify "on Percentile" (pending = resolve_pending test_selection.advanced_stats) <| @@ -1050,21 +1050,21 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Percentile 0.3 "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.at 0 . should_equal 2.2 t2 = table_builder [["X", [Nothing, neg_inf, neg_inf, 3, 4, pos_inf]]] r2 = t2.aggregate [Percentile 0.25 "X"] r2.row_count.should_equal 1 m2 = materialize r2 - m2.columns.length . should_equal 1 + m2.column_count . should_equal 1 m2.columns.first.at 0 . should_equal neg_inf t3 = table_builder [["X", [Nothing, neg_inf, neg_inf, pos_inf, pos_inf, pos_inf]]] r3 = t3.aggregate [Percentile 0.3 "X"] r3.row_count.should_equal 1 m3 = materialize r3 - m3.columns.length . should_equal 1 + m3.column_count . should_equal 1 expect_null_or_nan <| m3.columns.first.at 0 Test.specify "on Standard_Deviation" (pending = resolve_pending test_selection.std_dev) <| @@ -1072,7 +1072,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Standard_Deviation "X" (population=True), Standard_Deviation "X" (population=False)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 expect_null_or_nan <| m1.columns.first.at 0 expect_null_or_nan <| m1.columns.second.at 0 @@ -1083,7 +1083,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Average "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 Double.isNaN (m1.columns.first.at 0) . should_be_true Test.specify "on Median" (pending = resolve_pending test_selection.advanced_stats) <| @@ -1091,7 +1091,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Median "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 Double.isNaN (m1.columns.first.at 0) . should_be_true Test.specify "on Percentile" (pending = resolve_pending test_selection.advanced_stats) <| @@ -1099,7 +1099,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Percentile 0.3 "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 Double.isNaN (m1.columns.first.at 0) . should_be_true Test.specify "on Mode" (pending = resolve_pending test_selection.advanced_stats) <| @@ -1107,7 +1107,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Mode "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 Double.isNaN (m1.columns.first.at 0) . should_be_true Test.specify "on Standard_Deviation" (pending = resolve_pending test_selection.std_dev) <| @@ -1115,7 +1115,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Standard_Deviation "X" (population=False), Standard_Deviation "X" (population=True)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 Double.isNaN (m1.columns.first.at 0) . should_be_true Double.isNaN (m1.columns.second.at 0) . should_be_true @@ -1125,7 +1125,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [Mode "X"] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 1 + m1.column_count . should_equal 1 m1.columns.first.at 0 . should_equal 2 Test.group prefix+"Table.aggregate First and Last" pending=pending <| @@ -1135,7 +1135,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te r1 = t1.aggregate [First "X" (order_by=order), Last "X" (order_by=order)] r1.row_count.should_equal 1 m1 = materialize r1 - m1.columns.length . should_equal 2 + m1.column_count . should_equal 2 first = m1.columns.first.at 0 last = m1.columns.second.at 0 (first != last).should_be_true @@ -1146,7 +1146,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te grouped = table.aggregate [Group_By "B", Group_By "A"] grouped.row_count . should_equal 3 materialized = materialize grouped . order_by (Sort_Column_Selector.By_Name [Sort_Column.Name "A", Sort_Column.Name "B"]) - materialized.columns.length . should_equal 2 + materialized.column_count . should_equal 2 materialized.columns.at 1 . name . should_equal "A" materialized.columns.at 1 . to_vector . should_equal [1, 1, 2] materialized.columns.at 0 . name . should_equal "B" @@ -1159,7 +1159,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te tester result = result.row_count . should_equal 1 materialized = materialize result - materialized.columns.length . should_equal 1 + materialized.column_count . should_equal 1 materialized.columns.first.name . should_equal "Sum A" materialized.columns.first.to_vector . should_equal [6] problems = [Unsupported_Database_Operation_Error "`First` aggregation requires at least one `order_by` column.", Unsupported_Database_Operation_Error "`Last` aggregation requires at least one `order_by` column."] @@ -1318,7 +1318,7 @@ aggregate_spec prefix table empty_table table_builder materialize is_database te if is_database then Test.group prefix+"Table.aggregate should report unsupported operations but not block other aggregations in warning mode" pending=pending <| expect_sum_and_unsupported_errors error_count result = - result.columns.length . should_equal 1 + result.column_count . should_equal 1 result.row_count . should_equal 1 result.columns.first.to_vector . should_equal [6] warnings = Warning.get_all result . map .value diff --git a/test/Table_Tests/src/Common_Table_Spec.enso b/test/Table_Tests/src/Common_Table_Spec.enso index 599e5949b727..a08f61ba2c74 100644 --- a/test/Table_Tests/src/Common_Table_Spec.enso +++ b/test/Table_Tests/src/Common_Table_Spec.enso @@ -69,9 +69,9 @@ spec prefix table_builder test_selection pending=Nothing = table.at 100 . should_fail_with Index_Out_Of_Bounds_Error - Test.group prefix+"Table.length" pending=pending <| + Test.group prefix+"Table.column_count" pending=pending <| Test.specify "should allow getting the column count" <| - table.length . should_equal 7 + table.column_count . should_equal 7 Test.group prefix+"Table.select_columns" pending=pending <| Test.specify "should work as shown in the doc examples" <| diff --git a/test/Table_Tests/src/Database/Codegen_Spec.enso b/test/Table_Tests/src/Database/Codegen_Spec.enso index 0987b590bf41..c01014c89225 100644 --- a/test/Table_Tests/src/Database/Codegen_Spec.enso +++ b/test/Table_Tests/src/Database/Codegen_Spec.enso @@ -64,7 +64,7 @@ spec = empty = t1.select_columns (By_Name []) json = Json.from_pairs [["query", Nothing], ["message", "The table has no columns so a query cannot be generated."]] empty.to_json . should_equal json - empty.columns.length . should_equal 0 + empty.column_count . should_equal 0 empty.to_sql . should_fail_with Unsupported_Database_Operation_Error Test.group "[Codegen] Building Expressions" <| diff --git a/test/Table_Tests/src/Database/Common_Spec.enso b/test/Table_Tests/src/Database/Common_Spec.enso index 4faa6b2bb5e3..2eee1ed3e37d 100644 --- a/test/Table_Tests/src/Database/Common_Spec.enso +++ b/test/Table_Tests/src/Database/Common_Spec.enso @@ -55,7 +55,7 @@ spec prefix connection pending=Nothing = ix2.to_vector . should_equal [1, 4] Test.specify "should work correctly when there are no columns" <| empty = t1.select_columns (By_Name []) - empty.to_dataframe.columns.length . should_equal 0 + empty.to_dataframe.column_count . should_equal 0 empty.to_dataframe.row_count . should_equal empty.row_count Test.specify "should handle bigger result sets" <| n = 1000 @@ -206,8 +206,8 @@ spec prefix connection pending=Nothing = r.at "a" . to_vector . should_equal [1, 2, 3] empty = t4.drop_missing_columns - empty.columns.length . should_equal 0 - empty.to_dataframe.columns.length . should_equal 0 + empty.column_count . should_equal 0 + empty.to_dataframe.column_count . should_equal 0 Test.group prefix+"Column-wide statistics" pending=pending <| Test.specify 'should allow computing basic column-wide stats' <| diff --git a/test/Table_Tests/src/Database/Postgres_Spec.enso b/test/Table_Tests/src/Database/Postgres_Spec.enso index 3c262999d835..75d61e11d4bd 100644 --- a/test/Table_Tests/src/Database/Postgres_Spec.enso +++ b/test/Table_Tests/src/Database/Postgres_Spec.enso @@ -62,7 +62,7 @@ postgres_specific_spec connection pending = Test.specify "Counts" <| r = t.aggregate [Count, Count_Empty "txt", Count_Not_Empty "txt", Count_Distinct "i1", Count_Not_Nothing "i2", Count_Nothing "i3"] - r.columns.length . should_equal 6 + r.column_count . should_equal 6 r.columns.each column-> column.sql_type . should_equal Sql_Type.bigint diff --git a/test/Table_Tests/src/Excel_Spec.enso b/test/Table_Tests/src/Excel_Spec.enso index 85636320ce47..183f362fdc71 100644 --- a/test/Table_Tests/src/Excel_Spec.enso +++ b/test/Table_Tests/src/Excel_Spec.enso @@ -45,7 +45,7 @@ spec_fmt header file read_method = Test.specify "should read an empty table" <| t = read_method file (File_Format.Excel (Sheet "Empty")) - t.columns.length.should_equal 0 + t.column_count.should_equal 0 Test.specify "should gracefully handle duplicate column names and formulas" <| t = read_method file (File_Format.Excel (Sheet "Duplicate Columns")) @@ -59,13 +59,13 @@ spec_fmt header file read_method = t_1.at 'Price' . to_vector . should_equal [22.3, 32, 43.2, 54, 31, Nothing] t_2 = read_method file (File_Format.Excel (Cell_Range "Simple!3:5") headers=False) - t_2.columns.length.should_equal 3 + t_2.column_count.should_equal 3 t_2.at 'A' . to_vector . should_equal ['t-shirt', 'trousers', 'shoes'] t_2.at 'B' . to_vector . should_equal [20, Nothing, 30] t_2.at 'C' . to_vector . should_equal [32, 43.2, 54] t_3 = read_method file (File_Format.Excel (Cell_Range "Simple!B4:C5") headers=False) - t_3.columns.length.should_equal 2 + t_3.column_count.should_equal 2 t_3.at 'B' . to_vector . should_equal [Nothing, 30] t_3.at 'C' . to_vector . should_equal [43.2, 54] @@ -480,7 +480,7 @@ spec = start.up_to col.length . map i->(col.at i . should_equal (expected.at (i - start))) check_table table = - table.columns.length . should_equal 3 + table.column_count . should_equal 3 check_column (table.at "A") col_a check_column (table.at "B") col_b ## ToDo [JD]: Can't check Dates at present as not being handled correctly. Coming as a Polyglot array @@ -589,7 +589,7 @@ spec = file = enso_project.data / "RangeTests.xlsx" check_table table col_names data = - table.columns.length . should_equal col_names.length + table.column_count . should_equal col_names.length table.columns.map .name . should_equal col_names data.each_with_index idx->values-> table.at (col_names.at idx) . to_vector . should_equal values diff --git a/test/Table_Tests/src/Table_Date_Spec.enso b/test/Table_Tests/src/Table_Date_Spec.enso index eda8481e0f6b..1dadf4a0819d 100644 --- a/test/Table_Tests/src/Table_Date_Spec.enso +++ b/test/Table_Tests/src/Table_Date_Spec.enso @@ -21,7 +21,7 @@ spec = Test.group "File.read (Delimited) should work with Dates" <| table = (enso_project.data / "prime_ministers.csv").read Test.specify "should be able to read in a table with dates" <| - table.columns.length.should_equal 5 + table.column_count.should_equal 5 table.columns.map (.name) . should_equal ['Number','Party', 'Title', 'From', 'To'] table.row_count.should_equal 7 diff --git a/test/Table_Tests/src/Table_Spec.enso b/test/Table_Tests/src/Table_Spec.enso index e9ddacbd8e16..c9b867a360ec 100644 --- a/test/Table_Tests/src/Table_Spec.enso +++ b/test/Table_Tests/src/Table_Spec.enso @@ -429,7 +429,7 @@ spec = r = t_1.concat t_2 - r.columns.length.should_equal 2 + r.column_count.should_equal 2 r.at 'foo' . to_vector . should_equal [1, 2, 3, 4, 5, 6, 7] r.at 'bar' . to_vector . should_equal ['baz', 'quux', 'spam', 'eggs', False, True, False] @@ -444,7 +444,7 @@ spec = r = t_1.concat t_2 - r.columns.length.should_equal 3 + r.column_count.should_equal 3 r.at 'foo' . to_vector . should_equal [1, 2, 3, 4, 5, 6, 7] r.at 'bar' . to_vector . should_equal ['baz', 'quux', 'spam', 'eggs', Nothing, Nothing, Nothing] r.at 'baz' . to_vector . should_equal [Nothing, Nothing, Nothing, Nothing, False, True, False]