-
Notifications
You must be signed in to change notification settings - Fork 819
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
Support casting to/from DataType::Null
in cast
kernel
#1572
Conversation
@alamb @Dandandan plz have a review, thank you. |
Codecov Report
@@ Coverage Diff @@
## master #1572 +/- ##
==========================================
+ Coverage 82.87% 82.93% +0.05%
==========================================
Files 193 193
Lines 55304 55343 +39
==========================================
+ Hits 45835 45897 +62
+ Misses 9469 9446 -23
Continue to review full report at Codecov.
|
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.
This looks good to me, thank you 👍. Left some minor test suggestions
| LargeList(_) | ||
| FixedSizeList(_, _) | ||
| Struct(_) | ||
| Map(_, _) | ||
| Dictionary(_, _), | ||
Null, | ||
) => Ok(new_null_array(to_type, array.len())), |
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.
I've confirmed that these types are all supported by new_null_array
arrow/src/compute/kernels/cast.rs
Outdated
// cast null from and to struct | ||
let data_type = | ||
DataType::Struct(vec![Field::new("data", DataType::Int64, false)]); | ||
cast_from_and_to_null!(data_type); |
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.
Map?
} | ||
|
||
#[test] | ||
fn test_cast_null_from_and_to_variable_sized() { |
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.
Maybe fixed size also whilst here?
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.
Even better now 😄
cc @alamb @Dandandan @yjshen PTAL, thank you. |
DataType::Null
from and to othersDataType::Null
in cast
kernel
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.
Nice -- thanks @WinkerDu !
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
Thanks @yjshen ❤️ |
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
* cast null from and to others * fmt fix * add more ut Co-authored-by: duripeng <[email protected]>
Which issue does this PR close?
Closes #684.
Rationale for this change
Casting from
DataType::Null
to many other types is not allowed for now, likeDataType::Null
<->DataType::Utf8
, apache/arrow-datafusion#1188 depends on this casting ability to solveNULL
constant issue in function callWhat changes are included in this PR?
Allow casting
DataType::Null
from and to most of types except forDataType::Union
andDataType::Decimal
, which is not supported inarrow-rs/arrow/src/array/array.rs
Line 440 in 5dca6f0
Are there any user-facing changes?
No.