Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update schema in udfs #4165

Merged
merged 2 commits into from Jul 27, 2022
Merged

update schema in udfs #4165

merged 2 commits into from Jul 27, 2022

Conversation

ritchie46
Copy link
Member

fixes #4157

@github-actions github-actions bot added python Related to Python Polars rust Related to Rust Polars labels Jul 27, 2022
@ritchie46
Copy link
Member Author

@stinodego I get a flake8 linting error after a black run? Should we ignore that flake8 lint?

Black should decide the spacing.

@stinodego
Copy link
Member

stinodego commented Jul 27, 2022

@stinodego I get a flake8 linting error after a black run? Should we ignore that flake8 lint?

Black should decide the spacing.

I'll check in a sec.

EDIT:

@ritchie46 This is a bug in black. There have been similar issues before, like this one. black should reformat when you add a trailing comma to a list/dict/etc. In this case, apparently black doesn't know how to.

We can take this to the black bug tracker. Easiest fix for now is to manually remove the trailing commas in both dicts, so you get:

def test_update_schema_after_projection_pd_4157() -> None:
    assert pl.DataFrame({"c0": [], "c1": [], "c2": []}).lazy().rename(
        {"c2": "c2_"}
    ).drop("c2_").select(pl.col("c0")).collect().columns == ["c0"]

Or actually this would be prettier, in my opinion (again with trailing commas removed):

def test_update_schema_after_projection_pd_4157() -> None:
    result = (
        pl.DataFrame({"c0": [], "c1": [], "c2": []})
        .lazy()
        .rename({"c2": "c2_"})
        .drop("c2_")
        .select(pl.col("c0"))
        .collect()
    )
    assert result.columns == ["c0"]

@ritchie46
Copy link
Member Author

Alright. I'll see if we can update black. Maybe this bug is already resolved in a later version. Thanks for the explanation.

@stinodego
Copy link
Member

stinodego commented Jul 27, 2022

Alright. I'll see if we can update black. Maybe this bug is already resolved in a later version. Thanks for the explanation.

I tried the latest black version, but that doesn't help, unfortunately.

Updating black is a good idea anyway, though. Does not seem to impact any code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Projection pushdown NotFound error after rename->drop
2 participants