-
Notifications
You must be signed in to change notification settings - Fork 120
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
SNOW-929218 Add type coercion support for CaseWhen and Iff #1737
Conversation
Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing |
@@ -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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this 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)): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
460ddcc
to
43db83f
Compare
Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing |
Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing |
Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing |
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-929218
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.