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Β§
StructsΒ§
- Cast
Options - CastOptions provides a way to override the default cast behaviors
TraitsΒ§
- Decimal
Cast - 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_typecan be cast into a value ofto_type. - cast
- Cast
arrayto the provided data type and return a new Array with typeto_type, if possible. - cast_
binary_ πto_ fixed_ size_ binary - Helper function to cast from one
BinaryArrayor βLargeBinaryArrayβ to βFixedSizeBinaryArrayβ. - cast_
bool_ πto_ numeric - Cast Boolean types to numeric
- cast_
byte_ πcontainer - Helper function to cast from one
ByteArrayTypeto 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
BinaryArrayor β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
ByteViewTypearray toByteArrayTypearray. - cast_
with_ options - Try to cast
arraytoto_typeif 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