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

SNOW-929218 Add type coercion support for CaseWhen and Iff #1737

Merged
merged 8 commits into from
Jun 12, 2024

Conversation

sfc-gh-stan
Copy link
Collaborator

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-929218

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Copy link

github-actions bot commented Jun 5, 2024

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

@sfc-gh-stan sfc-gh-stan requested a review from a team June 5, 2024 17:24
@@ -336,6 +337,10 @@ def mock_to_date(

[x] For all other values, a conversion error is generated.
"""

if isinstance(column.sf_type.datatype, DateType):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When a column of type x gets casted to type x, it shouldn't raise error. Same for the changes below

@@ -1130,6 +1147,10 @@ def convert_num_to_bool(x: Optional[Real]):
new_col = column.apply(lambda x: try_convert(convert_num_to_bool, try_cast, x))
new_col.sf_type = ColumnType(BooleanType(), column.sf_type.nullable)
return new_col
elif isinstance(column.sf_type.datatype, VariantType):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Variant to Boolean is supported.

@sfc-gh-stan sfc-gh-stan marked this pull request as ready for review June 5, 2024 17:47
@sfc-gh-stan sfc-gh-stan requested a review from a team as a code owner June 5, 2024 17:47
@sfc-gh-stan sfc-gh-stan added local testing Local Testing issues/PRs and removed local-testing labels Jun 5, 2024
Copy link
Contributor

@sfc-gh-jrose sfc-gh-jrose left a comment

Choose a reason for hiding this comment

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

Awesome PR 🎉

Are there additional mock unit tests that should be added to more directly test the new helper functions?

return MapType(key_type=VariantType(), value_type=VariantType())
elif isinstance(t2, VariantType):
return t2
elif isinstance(t1, (TimeType, TimestampType, MapType, ArrayType)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Logically I think TimeType -> TimestampType and DateType -> TimestampType should be valid as well, but I'm not sure if that holds up in practice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DateType -> TimestampType is supported on line 284, TimeType -> TimestampType is not supported by my tests.

@sfc-gh-stan sfc-gh-stan requested review from sfc-gh-jdu and removed request for sfc-gh-yuwang June 7, 2024 19:00
@sfc-gh-stan sfc-gh-stan force-pushed the stan-add-coercion-support-for-known-places branch from 460ddcc to 43db83f Compare June 12, 2024 00:10
Copy link

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

@sfc-gh-stan sfc-gh-stan enabled auto-merge (squash) June 12, 2024 00:12
Copy link

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

Copy link

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

@sfc-gh-jrose sfc-gh-jrose disabled auto-merge June 12, 2024 20:32
@sfc-gh-jrose sfc-gh-jrose merged commit f6adc9a into main Jun 12, 2024
35 of 36 checks passed
@sfc-gh-jrose sfc-gh-jrose deleted the stan-add-coercion-support-for-known-places branch June 12, 2024 22:50
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
local testing Local Testing issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants