Skip to content

Commit

Permalink
Merge branch 'develop' into wip/jd/codeowners
Browse files Browse the repository at this point in the history
  • Loading branch information
jdunkerley authored Feb 3, 2022
2 parents a960e0e + d3c0f96 commit 6cec27a
Show file tree
Hide file tree
Showing 17 changed files with 998 additions and 92 deletions.
3 changes: 3 additions & 0 deletions app/gui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
ensured it fails with a dataflow error on out of bounds access instead of an
internal Java exception.][3232]
- [Implemented the `Table.select_columns` operation.][3230]
- [Implemented the `Table.remove_columns` and `Table.reorder_columns`
operations.][3240]

[3153]: https://github.com/enso-org/enso/pull/3153
[3166]: https://github.com/enso-org/enso/pull/3166
Expand All @@ -40,6 +42,7 @@
[3231]: https://github.com/enso-org/enso/pull/3231
[3232]: https://github.com/enso-org/enso/pull/3232
[3230]: https://github.com/enso-org/enso/pull/3230
[3240]: https://github.com/enso-org/enso/pull/3240

# Enso 2.0.0-alpha.18 (2021-10-12)

Expand Down
124 changes: 119 additions & 5 deletions distribution/lib/Standard/Database/0.2.32-SNAPSHOT/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import Standard.Table.Data.Table as Materialized_Table
import Standard.Table.Internal.Java_Exports
import Standard.Table.Internal.Table_Helpers

from Standard.Database.Data.Column as Column_Module import all
from Standard.Database.Data.Column as Column_Module import Column, Aggregate_Column
from Standard.Database.Data.Internal.IR import Internal_Column
from Standard.Table.Data.Order_Rule as Order_Rule_Module import Order_Rule
from Standard.Table.Data.Table import No_Such_Column_Error
from Standard.Table.Data.Column_Selector as Column_Selector_Module import all
from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import all
from Standard.Table.Data.Order_Rule as Order_Rule_Module import Order_Rule
from Standard.Table.Data.Column_Selector as Column_Selector_Module import Column_Selector, By_Index
from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import Problem_Behavior, Report_Warning
import Standard.Table.Data.Position
import Standard.Base.Error.Warnings

polyglot java import java.sql.JDBCType
Expand Down Expand Up @@ -112,7 +113,7 @@ type Table
> Example
Select columns by name.

table.select_columns (By_Name ["bar", "foo"] (Matching.Exact True))
table.select_columns (By_Name.new ["bar", "foo"])

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
Expand All @@ -138,6 +139,119 @@ type Table
new_columns = Table_Helpers.select_columns internal_columns=this.internal_columns selector=columns reorder=reorder on_problems=on_problems warnings=warnings
this.updated_columns new_columns

## Returns a new table with the chosen set of columns, as specified by the
`columns`, removed from the input table. Any unmatched input columns will
be kept in the output. Columns are returned in the same order as in the
input.

Arguments:
- columns: Criteria specifying which columns should be removed.
- on_problems: Specifies how to handle problems if they occur, reporting
them as warnings by default.

The following problems can occur:
- If a column in columns is not in the input table, a
`Missing_Input_Columns`.
- If duplicate columns, names or indices are provided, a
`Duplicate_Column_Selectors`.
- If a column index is out of range, a `Column_Indexes_Out_Of_Range`.
- If two distinct indices would refer to the same column, a
`Input_Indices_Already_Matched`, indicating that the additional
indices will not introduce additional columns.
- If there are no columns in the output table, a `No_Output_Columns`.
- warnings: A `Warning_System` instance specifying how to handle
warnings. This is a temporary workaround to allow for testing the
warning mechanism. Once the proper warning system is implemented, this
argument will become obsolete and will be removed. No user code should
use this argument, as it will be removed in the future.

> Example
Remove columns with given names.

table.remove_columns (By_Name.new ["bar", "foo"])

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
See: https://github.com/enso-org/enso/issues/1600

> Example
Remove columns matching a regular expression.

table.remove_columns (By_Name ["foo.+", "b.*"] (Matching.Regex case_senitivity=Matching.Case_Insensitive))

> Example
Remove the first two columns and the last column.

table.remove_columns (By_Index [-1, 0, 1])

> Example
Remove columns with the same names as the ones provided.

table.remove_columns (By_Column [column1, column2])
remove_columns : Column_Selector -> Problem_Behavior -> Warnings.Warning_System -> Table
remove_columns (columns = By_Index [0]) (on_problems = Report_Warning) (warnings = Warnings.default) =
new_columns = Table_Helpers.remove_columns internal_columns=this.internal_columns selector=columns on_problems=on_problems warnings=warnings
this.updated_columns new_columns

## Returns a new table with the specified selection of columns moved to
either the start or the end in the specified order.

Arguments:
- columns: Criteria specifying which columns should be reordered and
specifying their order.
- position: Specifies how to place the selected columns in relation to
the remaining columns which were not matched by `columns` (if any).
- on_problems: Specifies how to handle problems if they occur, reporting
them as warnings by default.

The following problems can occur:
- If a column in columns is not in the input table, a
`Missing_Input_Columns`.
- If duplicate columns, names or indices are provided, a
`Duplicate_Column_Selectors`.
- If a column index is out of range, a `Column_Indexes_Out_Of_Range`.
- If two distinct indices would refer to the same column, a
`Input_Indices_Already_Matched`, indicating that the additional
indices will not introduce additional columns.
- warnings: A `Warning_System` instance specifying how to handle
warnings. This is a temporary workaround to allow for testing the
warning mechanism. Once the proper warning system is implemented, this
argument will become obsolete and will be removed. No user code should
use this argument, as it will be removed in the future.

> Example
Move a column with a specified name to back.

table.reorder_columns (By_Name.new ["foo"]) position=After_Other_Columns

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
See: https://github.com/enso-org/enso/issues/1600

> Example
Move columns matching a regular expression to front, keeping columns matching "foo.+" before columns matching "b.*".

table.reorder_columns (By_Name ["foo.+", "b.*"] (Matching.Regex case_senitivity=Matching.Case_Insensitive))

> Example
Swap the first two columns.

table.reorder_columns (By_Index [1, 0]) position=Before_Other_Columns

> Example
Move the first column to back.

table.reorder_columns (By_Index [0]) position=After_Other_Columns

> Example
Move the columns with names matching the provided columns to the front.

table.reorder_columns (By_Column [column1, column2])
reorder_columns : Column_Selector -> Position.Position -> Problem_Behavior -> Warnings.Warning_System -> Table
reorder_columns (columns = By_Index [0]) (position = Position.Before_Other_Columns) (on_problems = Report_Warning) (warnings = Warnings.default) =
new_columns = Table_Helpers.reorder_columns internal_columns=this.internal_columns selector=columns position=position on_problems=on_problems warnings=warnings
this.updated_columns new_columns

## PRIVATE

Resolves the column name to a column within this table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ type Column_Selector
The `matching_strategy` can be used to specify if the names should be
matched exactly or should be treated as regular expressions. It also
allows to specify if the matching should be case-sensitive.
type By_Name (names : Vector Text) (matching_strategy : Matching_Strategy = Exact True)
type By_Name (names : Vector Text) (matching_strategy : Matching_Strategy = Exact.new)

## Selects columns by their index.

The index of the first column in the table is 0. If the provided index is
negative, it counts from the end of the table (e.g. -1 refers to the last
column in the table).
type By_Index (indexes : Vector Number)
type By_Index (indexes : Vector Integer)

## Selects columns having exactly the same names as the columns provided in
the input.
Expand All @@ -27,3 +27,8 @@ type Column_Selector
this approach can be used to match columns with the same names as a set
of columns of some other table, for example, when preparing for a join.
type By_Column (columns : Vector Column)

## UNSTABLE
A temporary workaround to allow the By_Name constructor to work with default arguments.
By_Name.new : Vector Text -> Matching_Strategy -> By_Name
By_Name.new names (matching_strategy = Exact.new) = By_Name names matching_strategy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ from Standard.Base import all
import Standard.Base.Data.Locale
import Standard.Base.Data.Text.Regex as Regex_Module

from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import all
from Standard.Base.Error.Warnings import all
from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import Problem_Behavior, Report_Warning
from Standard.Base.Error.Warnings import Warning_System

## Strategy for matching names.
type Matching_Strategy
Expand All @@ -19,6 +19,16 @@ type Matching_Strategy
A name is matched if its name matches the provided regular expression.
type Regex (case_sensitivity : (True | Case_Insensitive) = True)

## UNSTABLE
A temporary workaround to allow the Exact constructor to work with default arguments.
Exact.new : (True | Case_Insensitive) -> Exact
Exact.new (case_sensitivity = True) = Exact case_sensitivity

## UNSTABLE
A temporary workaround to allow the Regex constructor to work with default arguments.
Regex.new : (True | Case_Insensitive) -> Regex
Regex.new (case_sensitivity = True) = Regex case_sensitivity

## UNSTABLE
Specifies that the operation should ignore case.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from Standard.Base import all

type Position
## UNSTABLE
Selected columns will be moved to the front of the output table.
type Before_Other_Columns

## UNSTABLE
Selected columns will be moved to the back of the output table.
type After_Other_Columns
120 changes: 117 additions & 3 deletions distribution/lib/Standard/Table/0.2.32-SNAPSHOT/src/Data/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import Standard.Table.Io.Format
import Standard.Table.Internal.Table_Helpers

from Standard.Table.Data.Order_Rule as Order_Rule_Module import Order_Rule
from Standard.Table.Data.Column_Selector as Column_Selector_Module import all
from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import all
from Standard.Table.Data.Column_Selector as Column_Selector_Module import Column_Selector, By_Index
from Standard.Base.Error.Problem_Behavior as Problem_Behavior_Module import Problem_Behavior, Report_Warning
import Standard.Table.Data.Position
import Standard.Base.Error.Warnings

polyglot java import org.enso.table.data.table.Table as Java_Table
Expand Down Expand Up @@ -267,7 +268,7 @@ type Table
> Example
Select columns by name.

table.select_columns (By_Name ["bar", "foo"] (Matching.Exact True))
table.select_columns (By_Name.new ["bar", "foo"])

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
Expand All @@ -292,6 +293,119 @@ type Table
new_columns = Table_Helpers.select_columns internal_columns=this.columns selector=columns reorder=reorder on_problems=on_problems warnings=warnings
here.new new_columns

## Returns a new table with the chosen set of columns, as specified by the
`columns`, removed from the input table. Any unmatched input columns will
be kept in the output. Columns are returned in the same order as in the
input.

Arguments:
- columns: Criteria specifying which columns should be removed.
- on_problems: Specifies how to handle problems if they occur, reporting
them as warnings by default.

The following problems can occur:
- If a column in columns is not in the input table, a
`Missing_Input_Columns`.
- If duplicate columns, names or indices are provided, a
`Duplicate_Column_Selectors`.
- If a column index is out of range, a `Column_Indexes_Out_Of_Range`.
- If two distinct indices would refer to the same column, a
`Input_Indices_Already_Matched`, indicating that the additional
indices will not introduce additional columns.
- If there are no columns in the output table, a `No_Output_Columns`.
- warnings: A `Warning_System` instance specifying how to handle
warnings. This is a temporary workaround to allow for testing the
warning mechanism. Once the proper warning system is implemented, this
argument will become obsolete and will be removed. No user code should
use this argument, as it will be removed in the future.

> Example
Remove columns with given names.

table.remove_columns (By_Name.new ["bar", "foo"])

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
See: https://github.com/enso-org/enso/issues/1600

> Example
Remove columns matching a regular expression.

table.remove_columns (By_Name ["foo.+", "b.*"] (Matching.Regex case_senitivity=Matching.Case_Insensitive))

> Example
Remove the first two columns and the last column.

table.remove_columns (By_Index [-1, 0, 1])

> Example
Remove columns with the same names as the ones provided.

table.remove_columns (By_Column [column1, column2])
remove_columns : Column_Selector -> Problem_Behavior -> Warnings.Warning_System -> Table
remove_columns (columns = By_Index [0]) (on_problems = Report_Warning) (warnings = Warnings.default) =
new_columns = Table_Helpers.remove_columns internal_columns=this.columns selector=columns on_problems=on_problems warnings=warnings
here.new new_columns

## Returns a new table with the specified selection of columns moved to
either the start or the end in the specified order.

Arguments:
- columns: Criteria specifying which columns should be reordered and
specifying their order.
- position: Specifies how to place the selected columns in relation to
the remaining columns which were not matched by `columns` (if any).
- on_problems: Specifies how to handle problems if they occur, reporting
them as warnings by default.

The following problems can occur:
- If a column in columns is not in the input table, a
`Missing_Input_Columns`.
- If duplicate columns, names or indices are provided, a
`Duplicate_Column_Selectors`.
- If a column index is out of range, a `Column_Indexes_Out_Of_Range`.
- If two distinct indices would refer to the same column, a
`Input_Indices_Already_Matched`, indicating that the additional
indices will not introduce additional columns.
- warnings: A `Warning_System` instance specifying how to handle
warnings. This is a temporary workaround to allow for testing the
warning mechanism. Once the proper warning system is implemented, this
argument will become obsolete and will be removed. No user code should
use this argument, as it will be removed in the future.

> Example
Move a column with a specified name to back.

table.reorder_columns (By_Name.new ["foo"]) position=After_Other_Columns

## TODO [RW] default arguments do not work on atoms, once this is fixed,
the above should be replaced with just `Matching.Exact`.
See: https://github.com/enso-org/enso/issues/1600

> Example
Move columns matching a regular expression to front, keeping columns matching "foo.+" before columns matching "b.*".

table.reorder_columns (By_Name ["foo.+", "b.*"] (Matching.Regex case_senitivity=Matching.Case_Insensitive))

> Example
Swap the first two columns.

table.reorder_columns (By_Index [1, 0]) position=Before_Other_Columns

> Example
Move the first column to back.

table.reorder_columns (By_Index [0]) position=After_Other_Columns

> Example
Move the columns with names matching the provided columns to the front.

table.reorder_columns (By_Column [column1, column2])
reorder_columns : Column_Selector -> Position.Position -> Problem_Behavior -> Warnings.Warning_System -> Table
reorder_columns (columns = By_Index [0]) (position = Position.Before_Other_Columns) (on_problems = Report_Warning) (warnings = Warnings.default) =
new_columns = Table_Helpers.reorder_columns internal_columns=this.columns selector=columns position=position on_problems=on_problems warnings=warnings
here.new new_columns

## ALIAS Filter Rows
ALIAS Mask Columns

Expand Down
Loading

0 comments on commit 6cec27a

Please sign in to comment.