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

Implement Table.replace for the database backend #8986

Merged
merged 94 commits into from
Feb 29, 2024

Conversation

GregoryTravis
Copy link
Contributor

Also implements Table.replace using a Map.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

t . should_equal table
Problems.expect_warning Empty_Error t

group_builder.specify "asdfasdfshould throw an error on an empty (but well-formed) lookup table and non-empty base table if allow_unmatched_rows=False" <|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
group_builder.specify "asdfasdfshould throw an error on an empty (but well-formed) lookup table and non-empty base table if allow_unmatched_rows=False" <|
group_builder.specify "should throw an error on an empty (but well-formed) lookup table and non-empty base table if allow_unmatched_rows=False" <|

Typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

not, and allow_unmatched_rows=False, throw
`Unmatched_Rows_In_Lookup` with the first row of the
table. Otherwise, attach a warning.
if base_table.row_count == 0 || allow_unmatched_rows then Warning.attach (Empty_Error.Error lookup_table) base_table else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if base_table.row_count == 0 || allow_unmatched_rows then Warning.attach (Empty_Error.Error lookup_table) base_table else
if base_table.row_count == 0 || allow_unmatched_rows then Warning.attach (Empty_Error.Error "lookup_table") base_table else

Without the quotes the message will contain the contents of the map. Which being empty won't be so informative for the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

respectively.
lookup_table_renamed = selected_lookup_columns . rename_columns (Map.from_vector [[from_column_resolved, duplicate_key_column_name], [to_column_resolved, column]])

warn_if_empty result_table = if lookup_table_renamed.row_count != 0 then result_table else Warning.attach (Empty_Error.Error lookup_table_renamed) result_table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
warn_if_empty result_table = if lookup_table_renamed.row_count != 0 then result_table else Warning.attach (Empty_Error.Error lookup_table_renamed) result_table
warn_if_empty result_table = if lookup_table_renamed.row_count != 0 then result_table else Warning.attach (Empty_Error.Error "lookup_table") result_table

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lookup_table = table_builder_typed [['x', []], ['z', []]] Value_Type.Integer
t = table.replace lookup_table 'x' . order_by ['y']
t . should_equal table
Problems.expect_warning Empty_Error t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Problems.expect_warning Empty_Error t
Problems.expect_warning (Empty_Error "lookup_table") t

If you go with my above change. But either way I think our tests should be more specific when testing errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@AdRiley AdRiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we need to change the Empty_Error arguments

Comment on lines 1573 to 1574
@from_column Widget_Helpers.make_column_name_selector
@to_column Widget_Helpers.make_column_name_selector
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't these from the lookup_table so the selector is wrong?
We need to have widgets derived from first argument for this I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the notation would be for this -- is there documentation for the @ clauses? Or, where is it implemented? I don't see an example of a widget attached to a value other than self.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


## PRIVATE
The largest dataset that can be used to make a literal table, expressed in number of elements.
MAX_LITERAL_ELEMENT_COUNT = 256
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

256 a reasonable literal default. Agee with @radeusgd should be a temp table when gets bigger!

@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Feb 16, 2024
@GregoryTravis GregoryTravis removed the CI: Ready to merge This PR is eligible for automatic merge label Feb 16, 2024
@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Feb 16, 2024
@GregoryTravis GregoryTravis added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Feb 20, 2024
@GregoryTravis GregoryTravis linked an issue Feb 29, 2024 that may be closed by this pull request
@mergify mergify bot merged commit 54675b1 into develop Feb 29, 2024
25 of 26 checks passed
@mergify mergify bot deleted the wip/gmt/8578-Table.replace-db branch February 29, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new function Replace to Table.enso
4 participants