-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
arrowChanges to the arrow crateChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelogAny new improvement worthy of a entry in the changelog
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I want to cast a null constant in DataFusion to an array (so the expression evaluation logic is general). Sometimes this requires casting.
While this type of casting is definitely a corner case, it is required for completeness and will unify our handling of null constants in DataFusion
Describe the solution you'd like
I want the cast kernel to support casting to/from NullArray for all data types
Using Int8 as example, I want this code to work
// should be able to cast Int8Array to Null array
let input: ArrayRef = Arc::new(vec![Some(1), Some(2), None].into_iter().collect::<Int8Array>());
let cast = arrow::compute::cast(&input, &DataType::Null).expect("should work");
let expected = new_null_array(&DataType::Null, 3);
assert_eq!(&cast, &expected);Today it errors with:
thread 'main' panicked at 'should work: CastError("Casting from Int8 to Null not supported")', src/main.rs:15:62
And also I want to cast from Null to Int8:
// Likewise, should be able to cast NullArray to Int8Array
let input = new_null_array(&DataType::Null, 3);
let cast = arrow::compute::cast(&input, &DataType::Int8).expect("should work");
let expected = new_null_array(&DataType::Int8, 3);
assert_eq!(&cast, &expected);
// which is equivalent to
let expected: ArrayRef = Arc::new(vec![None, None, None].into_iter().collect::<Int8Array>());
assert_eq!(&cast, &expected);Which errors like this:
thread 'main' panicked at 'should work: CastError("Casting from Null to Int8 not supported")', src/main.rs:26:62
Describe alternatives you've considered
N/A
Additional context
See apache/datafusion#1179 and apache/datafusion#1184
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arrowChanges to the arrow crateChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelogAny new improvement worthy of a entry in the changelog