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 ๐
- map ๐
- run_
array ๐ - string ๐
- structs ๐
- union ๐
- Cast support for union arrays.
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_
num_ to_ bool - Cast numeric types to boolean
- 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_
single_ string_ to_ boolean_ default - Cast a single string to boolean with default cast option(safe=true).
- cast_
time64_ ๐to_ time32 - cast_
to_ ๐decimal - cast_
view_ ๐to_ byte - Helper function to cast from one
ByteViewTypearray toByteArrayTypearray. - cast_
with_ options - Try to cast
arraytoto_typeif possible. - integer_
to_ ๐decimal_ native - Convert an integer to a decimal native value without wrapping.
- make_
duration_ ๐array - make_
timestamp_ ๐array - num_
cast - Natural cast between numeric types
Return None if the input
valuecanโt be casted to typeO. - numeric_
cast ๐ - numeric_
to_ ๐bool_ cast - parse_
string_ to_ decimal_ native Deprecated - Parses the given string as a decimal with the given scale, returning the
unscaled representation in the decimal typeโs native integer (e.g.
i32forDecimal32Type,i256forDecimal256Type). - 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.
- single_
decimal_ to_ float_ lossy - Lossy conversion from decimal to float.
- single_
float_ to_ decimal - Cast a single floating point value to a decimal native with the given multiple.
Returns
Noneif the value cannot be represented with the requested precision. - time_
unit_ ๐multiple - Get the time unit as a multiple of a second
- timestamp_
to_ ๐date32 - try_
numeric_ ๐cast - union_
extract_ by_ type - Extracts the best-matching child array from a [
UnionArray] for a given target type, and casts it to that type.