Skip to content

Expr.rechunk does not rechunk in with_columns #22262

Open
@mcrumiller

Description

@mcrumiller

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Issue description

Using a modified example from the docs, if we replace .select with .with_columns we do not get a rechunked series:

import polars as pl
from polars import col

df = pl.DataFrame({"a": [1, 2]})
df = df.select(pl.repeat(None, 1).append(col("a")))
# shape: (3, 1)
# ┌────────┐
# │ repeat │
# │ ---    │
# │ i64    │
# ╞════════╡
# │ null   │ <-- chunk 1
# │ 1      │ <-- chunk 2
# │ 2      │
# └────────┘

df.select(col("repeat").rechunk()).n_chunks()
# 1

df.with_columns(col("repeat").rechunk()).n_chunks()
# 2

Installed versions

main

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageAwaiting prioritization by a maintainerpythonRelated to Python Polars

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions