Skip to content

Casting#

Casting Matrix#

This matrix is a high-level overview of the compatible casts between Daft DataTypes.

Casting can be done via the cast function. It is also performed implicitly in certain operations, such as to match a returned value to the specified return_dtype in a UDF, or when calling Series.from_pylist with a specified dtype.

🟢 = can cast

🔴 = cannot cast

FROM ↓ \ TO → Null Boolean Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 Decimal128 Timestamp Date Time Duration Interval Binary FixedSizeBinary Utf8 List FixedSizeList Struct Map Embedding Image FixedShapeImage Tensor FixedShapeTensor SparseTensor FixedShapeSparseTensor Python File
Null 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢
Boolean 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Int8 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Int16 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Int32 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Int64 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
UInt8 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
UInt16 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
UInt32 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
UInt64 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Float32 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Float64 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Decimal128 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Timestamp 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Date 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Time 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Duration 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Interval 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴
Binary 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🟢 🟢 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
FixedSizeBinary 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Utf8 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🟢 🟢 🟢 🔴 🟢 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
List 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🟢 🟢 🔴 🔴 🔴 🟢 🔴 🔴 🟢 🔴
FixedSizeList 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🟢 🔴 🟢 🔴 🟢 🔴 🔴 🟢 🔴
Struct 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🔴 🟢 🟢 🔴 🟢 🔴 🟢 🟢 🟢 🔴
Map 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴
Embedding 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🔴 🔴 🔴 🟢 🟢 🟢 🔴 🔴 🟢 🔴
Image 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🟢 🟢 🟢 🔴 🔴 🟢 🔴
FixedShapeImage 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🔴 🔴 🟢 🟢 🟢 🟢 🔴 🔴 🟢 🔴
Tensor 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🟢 🔴 🟢 🟢 🟢 🟢 🟢 🔴 🟢 🔴
FixedShapeTensor 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🔴 🔴 🟢 🔴 🟢 🟢 🔴 🟢 🟢 🔴
SparseTensor 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🟢 🔴 🟢 🟢 🔴
FixedShapeSparseTensor 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🟢 🔴 🔴 🔴 🔴 🔴 🟢 🟢 🟢 🔴
Python 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢 🟢
File 🟢 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴 🔴

Note

Overflowing values will be wrapped, e.g. 256 will be cast to 0 for an unsigned 8-bit integer.