#22811·polars

add `get_value` in `KeyedPartitionContext`

Author: lonestikeCreated May 18, 2025Updated Sep 16, 2026
Labelsenhancement

Description

add a method to get a value based on the key in the KeyedPartitionContext, so we can write the callback more easily. For instance get_value below:

def cb(ctx) -> str:
    year = ctx.get_value("year")
    country = ctx.get_value("country")
    return f"year={year}/{country}_{ctx.in_part_idx}.parquet"

in the case where we use by=["year", "country"] in PartitionByKey

the implementation should be pretty straightforward.