liukun4515 commented on code in PR #1922:
URL: https://github.com/apache/arrow-rs/pull/1922#discussion_r905637663
##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -72,9 +72,9 @@ pub fn can_cast_types(from_type: &DataType, to_type:
&DataType) -> bool {
// cast one decimal type to another decimal type
(Decimal(_, _), Decimal(_, _)) => true,
// signed numeric to decimal
- (Int8 | Int16 | Int32 | Int64 | Float32 | Float64, Decimal(_, _)) |
+ (Null|Int8 | Int16 | Int32 | Int64 | Float32 | Float64, Decimal(_, _))
|
// decimal to signed numeric
- (Decimal(_, _), Int8 | Int16 | Int32 | Int64 | Float32 | Float64)
+ (Decimal(_, _), Null| Int8 | Int16 | Int32 | Int64 | Float32 | Float64)
Review Comment:
> I agree with @nevi-me that a preferable way would be:
>
> 1. Not allow `type` -> `NULL` in the `cast` and `try_cast` kernels
> 2. Add some other function (or maybe just add an example on the `cast`
documentation pointing at `new_null_array` as the way to "cast" any array to
null)
>
> I would personally suggest:
>
> 1. Add support in this PR to cast Decimal --> Null to be consistent with
other `cast` kernels
> 2. As a follow on PR (perhaps to close [Disallow cast from other datatypes
to NullType #1923](https://github.com/apache/arrow-rs/issues/1923)) we can then
remove the `type` -> `NULL` casts
agree with the proposal.
I think this pr can be merged if we follow above suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]