Skip to content

yggdrasil.arrow.python_defaults

python_defaults

Default value helpers for Python and Arrow types.

default_arrow_scalar

default_arrow_scalar(
    dtype: Union[DataType, ListType, MapType, StructType, FixedSizeListType],
    nullable: bool,
) -> pa.Scalar

Return a default scalar for a given Arrow type.

Parameters:

Name Type Description Default
dtype Union[DataType, ListType, MapType, StructType, FixedSizeListType]

Arrow data type.

required
nullable bool

Whether the scalar should be nullable.

required

Returns:

Type Description
Scalar

Arrow scalar default.

default_python_scalar

default_python_scalar(hint: Any) -> Any

Return a default Python value for the given type hint.

Parameters:

Name Type Description Default
hint Any

Type hint to generate defaults for.

required

Returns:

Type Description
Any

Default Python value.

default_scalar

default_scalar(
    hint: Union[type, DataType, Field], nullable: bool | None = None
) -> Any

Return a default scalar value for Python or Arrow type hints.

Parameters:

Name Type Description Default
hint Union[type, DataType, Field]

Python type or Arrow type/field.

required
nullable bool | None

Override nullability for Arrow types.

None

Returns:

Type Description
Any

Default scalar value.