Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial offset design ideas #12015

Draft
wants to merge 54 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
eb37ef5
Initial offset design ideas
AdRiley Jan 7, 2025
7989ce8
Offset Column design work
AdRiley Jan 9, 2025
b0bf1c8
Table design
AdRiley Jan 9, 2025
d8740d2
Start to add test framework
AdRiley Jan 9, 2025
1cd2aa6
Add set_mode
AdRiley Jan 9, 2025
5130f56
Green
AdRiley Jan 10, 2025
bd3768a
More tests
AdRiley Jan 10, 2025
cdffb5d
One more test
AdRiley Jan 10, 2025
b490f0a
Table.offset Red
AdRiley Jan 10, 2025
a74f5fa
Plumbing
AdRiley Jan 10, 2025
ee45c92
More plumbing
AdRiley Jan 10, 2025
da5ec3f
First table test green
AdRiley Jan 10, 2025
089cf05
Next green table test
AdRiley Jan 10, 2025
af95bdc
Next table tests
AdRiley Jan 10, 2025
0d2933f
Green
AdRiley Jan 13, 2025
b331d7d
Red
AdRiley Jan 13, 2025
937f851
Green using mask solution
AdRiley Jan 13, 2025
d01bd24
Refactor
AdRiley Jan 13, 2025
a811df6
refactor
AdRiley Jan 13, 2025
8a97331
Refactor
AdRiley Jan 13, 2025
5d44c4d
More green tests
AdRiley Jan 13, 2025
09664f0
Red
AdRiley Jan 13, 2025
7c41b53
Green
AdRiley Jan 13, 2025
ccfb97c
Refactor
AdRiley Jan 13, 2025
68181ad
Green
AdRiley Jan 13, 2025
1cda931
Red
AdRiley Jan 14, 2025
c1e663a
Green
AdRiley Jan 14, 2025
5b9f789
Green
AdRiley Jan 14, 2025
1119796
Green
AdRiley Jan 14, 2025
c999528
Red
AdRiley Jan 14, 2025
7a2fa9e
Green
AdRiley Jan 14, 2025
4afadeb
Ordering and closet fill
AdRiley Jan 14, 2025
7a60ce6
Green
AdRiley Jan 14, 2025
14ca426
Refactor
AdRiley Jan 14, 2025
b6acd89
Refactor
AdRiley Jan 14, 2025
74d80a8
Refactor
AdRiley Jan 14, 2025
64dde8a
Cleanup
AdRiley Jan 14, 2025
6de5c51
Refactor
AdRiley Jan 15, 2025
9309586
Documentaion
AdRiley Jan 15, 2025
c50fef4
Column Names
AdRiley Jan 15, 2025
f928e1e
Multiple columns
AdRiley Jan 16, 2025
1b37fa6
Refactor
AdRiley Jan 16, 2025
134b818
Refactor
AdRiley Jan 16, 2025
67f9137
Refactor
AdRiley Jan 16, 2025
b9c69e2
Refactor
AdRiley Jan 16, 2025
791740a
Refactor
AdRiley Jan 16, 2025
8df3f4c
set_mode=update
AdRiley Jan 16, 2025
1dd496d
More tests
AdRiley Jan 17, 2025
88a8063
Remove on_problems
AdRiley Jan 17, 2025
b572fde
Rename to Fill_With
AdRiley Jan 17, 2025
6a37f2d
Documentation
AdRiley Jan 17, 2025
1eeff6f
Revert "Remove on_problems"
AdRiley Jan 17, 2025
3d5c77d
fmt
AdRiley Jan 17, 2025
7819762
New alias
AdRiley Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Remove on_problems"
This reverts commit e59c7e9.
  • Loading branch information
AdRiley committed Jan 17, 2025
commit 1eeff6f248f05cc2090590b004a222384492d721
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Fill_With

## Fill_With.from (that:Any) = Fill_With.Constant that

table_offset_impl table:Table (columns:(Vector | Text | Integer | Regex)=[]) n:Integer=-1 fillWith:Fill_With=..Nothing (group_by:(Vector | Text | Integer | Regex)=[]) (order_by:(Vector | Text)=[]) (set_mode:Set_Mode=..Add) -> Table =
table_offset_impl table:Table (columns:(Vector | Text | Integer | Regex)=[]) n:Integer=-1 fillWith:Fill_With=..Nothing (group_by:(Vector | Text | Integer | Regex)=[]) (order_by:(Vector | Text)=[]) (set_mode:Set_Mode=..Add) (on_problems:Problem_Behavior=..Report_Warning) -> Table =
problem_builder = Problem_Builder.new error_on_missing_columns=True
resolved_columns = table.columns_helper.select_columns_helper columns Case_Sensitivity.Default True problem_builder
grouping_columns = table.columns_helper.select_columns_helper group_by Case_Sensitivity.Default True problem_builder
Expand All @@ -37,12 +37,12 @@ table_offset_impl table:Table (columns:(Vector | Text | Integer | Regex)=[]) n:I
grouping_java_columns = grouping_columns.map c->c.java_column
ordering_java_columns = ordering.map c->c.column.java_column
directions = ordering.map c->c.associated_selector.direction.to_sign
problem_builder.attach_problems_before ..Report_Error <|
problem_builder.attach_problems_before on_problems <|
new_names = resolved_columns.map c->
if set_mode!=Set_Mode.Add then c.name else
Column_Naming_Helper.in_memory.function_name "offset" [c, n, fillWith]
new_storages = Java_Problems.with_problem_aggregator Problem_Behavior.Report_Error java_problem_aggregator->
new_storages = Java_Problems.with_problem_aggregator on_problems java_problem_aggregator->
Java_Offset.offset resolved_java_columns n fillWith_java grouping_java_columns ordering_java_columns directions java_problem_aggregator
new_columns = new_names.zip new_storages.to_vector new_name-> new_storage -> Column.from_storage new_name new_storage
new_columns.fold table t-> c->
t.set c c.name
t.set c c.name set_mode
5 changes: 3 additions & 2 deletions distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,7 @@ type Table
- group_by: Applies the offset to each group as a separate batch of records.
- order_by: The order to slide the records through. The actual record order remains the same but the records move as per the order defined by these columns.
- set_mode: By default creates new columns, but choosing Update replaces the existing fields being offset.
- on_problems: Missing columns are always an error. Other warnings like grouping on floating point numbers can be ignored or made an error with this argument.

Returns:
- A Table of all records, with the selected columns offset by the number specifed by n.
Expand All @@ -3828,8 +3829,8 @@ type Table
@default (self-> Widget_Helpers.make_fill_default_value_selector2)
@group_by Widget_Helpers.make_column_name_multi_selector
@order_by Widget_Helpers.make_order_by_selector
offset self columns:(Vector (Integer | Text | Regex | By_Type))=(Missing_Argument.throw "columns") n:Integer=-1 fill_with:Fill_With=..Nothing (group_by:(Vector | Text | Integer | Regex)=[]) (order_by:(Vector | Text)=[]) (set_mode:Set_Mode=..Add) -> Table =
Offset.table_offset_impl self columns n fill_with group_by order_by set_mode
offset self columns:(Vector (Integer | Text | Regex | By_Type))=(Missing_Argument.throw "columns") n:Integer=-1 fill_with:Fill_With=..Nothing (group_by:(Vector | Text | Integer | Regex)=[]) (order_by:(Vector | Text)=[]) (set_mode:Set_Mode=..Add) (on_problems:Problem_Behavior=..Report_Warning) -> Table =
Offset.table_offset_impl self columns n fill_with group_by order_by set_mode on_problems

## PRIVATE
column_naming_helper : Column_Naming_Helper
Expand Down
15 changes: 14 additions & 1 deletion test/Table_Tests/src/Common_Table_Operations/Offset_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from Standard.Test import all

from Standard.Database.Errors import Unsupported_Database_Operation
import Standard.Database.Feature.Feature
import Standard.Base.Errors.Common.Missing_Argument
from Standard.Base.Errors.Common import Missing_Argument, Floating_Point_Equality
from Standard.Table.Errors import Missing_Input_Columns

from project.Common_Table_Operations.Util import run_default_backend
Expand Down Expand Up @@ -441,6 +441,7 @@ add_offset_specs suite_builder setup =
r . at "Col2" . to_vector . should_equal [Nothing, 1, 2, 3]
suite_builder.group prefix+"Table.Offset handles bad inputs gracefully" group_builder->
t2 = build_sorted_table [["Col1", ["A", "B", "C", "D"]], ["Col2", [1, 2, 3, 4]]]
t3 = build_sorted_table [["Group", [1.1, 1.1, 1.1, 1.1]], ["Col2", [1, 2, 3, 4]]]
group_builder.specify "Missing offset columns error" <|
r = t2.offset
r.should_fail_with (Missing_Argument.Error "columns")
Expand All @@ -457,5 +458,17 @@ add_offset_specs suite_builder setup =
group_builder.specify "Missing column is an error - ordering" <|
r = t2.offset [] order_by=["NotAColumn"]
r.should_fail_with (Missing_Input_Columns.Error ["NotAColumn"])
group_builder.specify "Grouping by float warns" <|
r = t3.offset ["Col2"] group_by=["Group"]
Problems.expect_warning Floating_Point_Equality r
r . at "offset([Col2], -1, Fill_With.Nothing)" . to_vector . should_equal [Nothing, 1, 2, 3]
group_builder.specify "Grouping by float errors if on_problems set" <|
r = t3.offset ["Col2"] group_by=["Group"] on_problems=..Report_Error
r.should_fail_with Floating_Point_Equality
group_builder.specify "Grouping by float errors can be silenced using on_problems" <|
r = t3.offset ["Col2"] group_by=["Group"] on_problems=..Ignore
Warning.get_all r wrap_errors=True . should_equal []
r . at "offset([Col2], -1, Fill_With.Nothing)" . to_vector . should_equal [Nothing, 1, 2, 3]



Loading