Skip to content

fix: polars 1.8.0 compatibility for list expr and null as_counts - #3

Merged
bjhardcastle merged 1 commit into
mainfrom
copilot/update-ci-workflow
Apr 13, 2026
Merged

bjhardcastle merged 1 commit into
mainfrom
copilot/update-ci-workflow

Conversation

Copilot AI commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Two tests fail against polars==1.8.0 (the declared minimum version) due to API differences.

Changes

  • test_join_between_vec_as_list_expr: pl.col("list_col") + scalar raises InvalidOperationError in polars 1.8.0 — scalar arithmetic doesn't broadcast into list elements until a later release. Replaced with the explicit list.eval(element() + 1) form, which is equivalent and works across all supported versions.

  • test_join_between_null_vec_row_as_counts / frame.py: In polars 1.8.0, list.len() returns 0 for null lists instead of null. The as_counts=True path was applying .list.len().cast(UInt32) inline in the expression, silently dropping nulls. Moved the conversion out of the plugin expression chain and applied it post-hoc with an explicit when/then/otherwise null guard:

clipped_series = (
    clipped_series
    .to_frame()
    .select(
        pl.when(pl.col(val_col_name).is_null())
        .then(pl.lit(None).cast(pl.UInt32))
        .otherwise(pl.col(val_col_name).list.len().cast(pl.UInt32))
        .alias(val_col_name)
    )
    [val_col_name]
)

Agent-Logs-Url: https://github.com/bjhardcastle/polars-vec-ops/sessions/1f688076-4840-45f1-ba5c-93632b4db00c

Co-authored-by: bjhardcastle <63425812+bjhardcastle@users.noreply.github.com>
@bjhardcastle
bjhardcastle marked this pull request as ready for review April 13, 2026 14:46
@bjhardcastle
bjhardcastle requested review from bjhardcastle and removed request for bjhardcastle April 13, 2026 14:47
@bjhardcastle
bjhardcastle merged commit 759dd93 into main Apr 13, 2026
7 of 10 checks passed
@bjhardcastle
bjhardcastle deleted the copilot/update-ci-workflow branch April 13, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants