Module cast

Module cast 

Source
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));

ModulesΒ§

decimal πŸ”’
dictionary πŸ”’
list πŸ”’
list_view πŸ”’
map πŸ”’
run_array πŸ”’
string πŸ”’

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Β§

adjust_timestamp_to_timezone πŸ”’
as_time_res_with_timezone πŸ”’
bool_to_numeric_cast πŸ”’
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_binary_to_fixed_size_binary πŸ”’
Helper function to cast from one BinaryArray or β€˜LargeBinaryArray’ to β€˜FixedSizeBinaryArray’.
cast_bool_to_numeric πŸ”’
Cast Boolean types to numeric
cast_byte_container πŸ”’
Helper function to cast from one ByteArrayType to another and vice versa. If the target one (e.g., LargeUtf8) is too large for the source array it will return an Error.
cast_duration_to_interval πŸ”’
Cast the array from duration and interval
cast_fixed_size_binary_to_binary πŸ”’
Helper function to cast from β€˜FixedSizeBinaryArray’ to one BinaryArray or β€˜LargeBinaryArray’. If the target one is too large for the source array it will return an Error.
cast_fixed_size_binary_to_binary_view πŸ”’
cast_from_decimal πŸ”’
cast_integer_to_decimal πŸ”’
cast_interval_day_time_to_interval_month_day_nano πŸ”’
Cast the array from interval day time to month day nano
cast_interval_year_month_to_interval_month_day_nano πŸ”’
Cast the array from interval year month to month day nano
cast_month_day_nano_to_duration πŸ”’
Cast the array from interval to duration
cast_numeric_arrays πŸ”’
Convert Array into a PrimitiveArray of type, and apply numeric cast
cast_numeric_to_binary πŸ”’
cast_numeric_to_bool πŸ”’
Cast numeric types to Boolean
cast_reinterpret_arrays πŸ”’
Cast the primitive array using [PrimitiveArray::reinterpret_cast]
cast_struct_fields_by_name πŸ”’
cast_struct_fields_in_order πŸ”’
cast_struct_to_struct πŸ”’
cast_to_decimal πŸ”’
cast_view_to_byte πŸ”’
Helper function to cast from one ByteViewType array to ByteArrayType array.
cast_with_options
Try to cast array to to_type if possible.
make_duration_array πŸ”’
make_timestamp_array πŸ”’
numeric_cast πŸ”’
numeric_to_bool_cast πŸ”’
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.
time_unit_multiple πŸ”’
Get the time unit as a multiple of a second
timestamp_to_date32 πŸ”’
try_numeric_cast πŸ”’