Skip to content

daft.functions.deserialize#

deserialize #

deserialize(expr: Expression, format: Literal['json'], dtype: DataTypeLike) -> Expression

Deserializes a string using the specified format and data type.

Parameters:

Name Type Description Default
expr Expression

The expression to deserialize.

required
format Literal['json']

The serialization format.

required
dtype DataTypeLike

The target data type to deserialize into.

required

Returns:

Name Type Description
Expression Expression

A new expression with the deserialized value.

Source code in daft/functions/str.py
13
14
15
16
17
18
19
20
21
22
23
24
25
def deserialize(expr: Expression, format: Literal["json"], dtype: DataTypeLike) -> Expression:
    """Deserializes a string using the specified format and data type.

    Args:
        expr: The expression to deserialize.
        format (Literal["json"]): The serialization format.
        dtype: The target data type to deserialize into.

    Returns:
        Expression: A new expression with the deserialized value.
    """
    dtype = DataType._infer(dtype)
    return Expression._call_builtin_scalar_fn("deserialize", expr, format=format, dtype=dtype._dtype)