Skip to content

daft.functions.try_decode#

try_decode #

try_decode(bytes: Expression, charset: ENCODING_CHARSET) -> Expression

Decode or null if unsuccessful.

See Also

daft.functions.decode

Source code in daft/functions/binary.py
81
82
83
84
85
86
87
88
89
def try_decode(bytes: Expression, charset: ENCODING_CHARSET) -> Expression:
    """Decode or null if unsuccessful.

    Tip: See Also
        [`daft.functions.decode`](https://docs.daft.ai/en/stable/api/functions/decode/)
    """
    # TODO: Replace with a try_cast to string if the charset is "utf-8" or "utf8"
    # We currently don't have a try_cast
    return Expression._call_builtin_scalar_fn("try_decode", bytes, codec=charset)