Skip to content

daft.functions.chunk#

chunk #

chunk(list_expr: Expression, size: int) -> Expression

Splits each list into chunks of the given size.

Parameters:

Name Type Description Default
list_expr List Expression

expression to chunk

required
size int

size of chunks to split the list into. Must be greater than 0

required

Returns:

Name Type Description
Expression List[FixedSizedList] Expression

expression with lists of fixed size lists of the type of the list values

Source code in daft/functions/list.py
47
48
49
50
51
52
53
54
55
56
57
58
def chunk(list_expr: Expression, size: int) -> Expression:
    """Splits each list into chunks of the given size.

    Args:
        list_expr (List Expression): expression to chunk
        size (int): size of chunks to split the list into. Must be greater than 0

    Returns:
        Expression (List[FixedSizedList] Expression):
            expression with lists of fixed size lists of the type of the list values
    """
    return Expression._call_builtin_scalar_fn("list_chunk", list_expr, size)