Skip to content

daft.functions.extract_month_uuid7#

extract_month_uuid7 #

extract_month_uuid7(expr: Expression) -> Expression

Partitioning Transform that extracts the number of calendar months since 1970-01 from a UUIDv7.

The result is (year - 1970) * 12 + (month - 1), matching partition_months. A UUIDv7 embeds a 48-bit Unix-millisecond timestamp in its first 6 bytes. The input must be a Uuid or a FixedSizeBinary of 16 bytes (128 bits).

Parameters:

Name Type Description Default
expr Expression

a Uuid or FixedSizeBinary(16) expression of UUIDv7 values

required

Returns:

Name Type Description
Expression Expression

Int64 Expression with the number of months since 1970-01

Source code in daft/functions/partition.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def extract_month_uuid7(expr: Expression) -> Expression:
    """Partitioning Transform that extracts the number of calendar months since 1970-01 from a UUIDv7.

    The result is `(year - 1970) * 12 + (month - 1)`, matching `partition_months`. A UUIDv7 embeds a
    48-bit Unix-millisecond timestamp in its first 6 bytes. The input must be a Uuid or a
    FixedSizeBinary of 16 bytes (128 bits).

    Args:
        expr: a Uuid or FixedSizeBinary(16) expression of UUIDv7 values

    Returns:
        Expression: Int64 Expression with the number of months since 1970-01
    """
    return Expression._call_builtin_scalar_fn("extract_month_uuid7", expr)