Skip to main content

Module cast

Module cast 

Expand description

Cast kernels to convert ArrayRef between supported datatypes.

See cast_with_options for more information on specific conversions.

Example:

// int32 to float64
let a = Int32Array::from(vec![5, 6, 7]);
let b = cast(&a, &DataType::Float64).unwrap();
let c = b.as_primitive::<Float64Type>();
assert_eq!(5.0, c.value(0));
assert_eq!(6.0, c.value(1));
assert_eq!(7.0, c.value(2));

Structs§

CastOptions
CastOptions provides a way to override the default cast behaviors

Traits§

DecimalCast
A utility trait that provides checked conversions between decimal types inspired by NumCast

Functions§

can_cast_types
Return true if a value of type from_type can be cast into a value of to_type.
cast
Cast array to the provided data type and return a new Array with type to_type, if possible.
cast_num_to_bool
Cast numeric types to boolean
cast_single_string_to_boolean_default
Cast a single string to boolean with default cast option(safe=true).
cast_with_options
Try to cast array to to_type if possible.
num_cast
Natural cast between numeric types Return None if the input value can’t be casted to type O.
rescale_decimal
Rescales a decimal value from (input_precision, input_scale) to (output_precision, output_scale) and returns the converted number when it fits within the output precision.
single_bool_to_numeric
Cast single bool value to numeric value.
union_extract_by_type
Extracts the best-matching child array from a UnionArray for a given target type, and casts it to that type.