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

Allow parse to pass through already matched type. #12016

Merged
merged 9 commits into from
Jan 8, 2025

Conversation

jdunkerley
Copy link
Member

@jdunkerley jdunkerley commented Jan 7, 2025

Pull Request Description

  • Table.parse and Column.parse will allow the target type to be returned unchanged.
  • Fix widget for Excel_Workbook.read_many.
  • Fix ALIAS for DB_Table.sort.
  • Fix Table.text_cleanse widget by adding a default value.
  • Expose In_Any_Warn_On_Missing for read_many as wanted by user in review.

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,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@jdunkerley jdunkerley added the CI: No changelog needed Do not require a changelog entry for this PR. label Jan 7, 2025
@jdunkerley
Copy link
Member Author

Closes #11991


c1 = t.at "X" . parse Value_Type.Integer
setup.expect_integer_type c1
c1.to_vector . should_equal [42, 0, -1]
c1.to_vector . should_equal v
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to make sure the column was returned directly?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could do

c1 = t.at "X"
r1 = c1.parse ..Integer
Meta.is_same_object c1 r1 . should_be_true

Comment on lines +2322 to +2324
column_value_type = column_to_parse.value_type
already_parsed = Auto != type && column_value_type.is_same_type type
if already_parsed then 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.

I've just realised that this check is redundant to the check in Column.parse.

We could discard this change altogether and all should still work - because we will just call parse on all selected columns and for those of them that already fit the target type, they will be returned as-is and passed to set - set updating a column to the same column effectively does nothing.

I think it could be a worthwhile simplification to remove this custom logic from Table.parse and only rely on Column.parse ensuring the correct behaviour. That way the logic is only in 2 places (because of also DB_Column) instead of 4.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

Looks good now.

I think we could further simplify a bit as the check inside of Table.parse seems redundant with Column.parse.

@jdunkerley jdunkerley added the CI: Ready to merge This PR is eligible for automatic merge label Jan 8, 2025
@mergify mergify bot merged commit da2898e into develop Jan 8, 2025
41 of 42 checks passed
@mergify mergify bot deleted the wip/jd/table-parse-tweaks branch January 8, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants