Types
DecimalType
dataclass
Bases: Type[Decimal]
A Typol Type with specializations for handling pl.Decimal
Source code in typol/types.py
__call__(value)
Create a literal value cast into this type, i.e. decimal(38, 8)(5) will be a pl.Decimal
To handle some known issues with Polars, this is overriden to explicitly cast to a Python decimal first
Source code in typol/types.py
StructMapping
Bases: Collection[Any], Protocol
A tag type for a column containing struct objects. This means accesses of these column values
will be able to see them as Mapping objects, but the field names are tracked too, so
expr.struct.field accesses can be checked against the shape
Source code in typol/types.py
Type
dataclass
A representation of a Polars type for Typol that allows it to track the associated Python type. This is tracked as a type parameter to allow constructing typed expressions, but also reified to allow any transformations that might be needed (such as with enums)
Source code in typol/types.py
__call__(value)
Create a literal value cast into this type, i.e. FLOAT_32(5) will be a f32
Source code in typol/types.py
datetime(unit='ms', time_zone=None)
decimal(precision=None, scale=0)
enum(enum)
Construct a Polars Enum around int or str-backed enum type enum
Source code in typol/types.py
from_typeable(t)
Normalize anything allowed to be the type of a column, either a Python or Typol type, into a Typol type
Source code in typol/types.py
integer_for(min_value, max_value)
Find a signed integer type that fits -min_value though max_value
Source code in typol/types.py
list_of(ty)
normalize_enum(value)
Normalize input values so enums are represented by their value rather than as objects
Source code in typol/types.py
struct_of(ty)
unsigned_integer_for(max_value)
Find an unsigned integer type that fits 0 though max_value