-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix(rust): follow function params & aliases for left-most name #13819
base: main
Are you sure you want to change the base?
Conversation
When deciding the schema for In addition, without this with_columns(
pl.when(pl.int_range(0, pl.len(), eager=False) < 2)
.then(None)
.otherwise(pl.all())
) |
Question: when you say "truthy" branch, do you mean the first input (in the With that aside....doesn't this mean that we can never do the following pattern? pl.when(pl.some_function()).then(something).otherwise(pl.all()) In other words, |
That's the purpose of pl.when(pl.col.c).then(None).otherwise(pl.all()).name.keep() |
Indeed! Thanks. Let me update the failing test. |
Hmm, it appears we can't do >>> pl.DataFrame({"a": [1, 2, 3]}).with_columns(pl.all().name.keep().name.suffix("_2"))
pyo3_runtime.PanicException: no `name.keep` expected at this point |
Also, how does |
@reswqa I've added a workaround to the renaming in the unit test, along with a note. It's a bit messier (now have to create seprate I still don't quite understand how |
A theoretical workaround: when using a
|
The key is that |
Alright. So should we just proceed as if this is now correct, and wait until someone runs into an issue in the future with the |
What do you mean by I can open a PR(It might be a little late because I have some things to do this weekend :)) that lets us support the following usage, Is this enough to address your concerns. pl.when(pl.int_range(0, pl.len(), eager=False) < 2)
.then(None)
.otherwise(pl.all())
.name.keep()
.name.suffix("_nulls") And it's results should be: ┌──────┬──────┬────────────┬────────────┐
│ col1 ┆ col2 ┆ col1_nulls ┆ col2_nulls │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 │
╞══════╪══════╪════════════╪════════════╡
│ 0 ┆ 6 ┆ null ┆ null │
│ 1 ┆ 5 ┆ null ┆ null │
│ 2 ┆ 4 ┆ 2 ┆ 4 │
│ 3 ┆ 3 ┆ 3 ┆ 3 │
│ 4 ┆ 2 ┆ 4 ┆ 2 │
│ 5 ┆ 1 ┆ 5 ┆ 1 │
│ 6 ┆ 0 ┆ 6 ┆ 0 │
└──────┴──────┴────────────┴────────────┘ |
Hmm, yes I think that works. I'm still struggling a bit to follow the expected behavior though. I understand that
The "root name" (I think) should be what's in the
|
Depending on how you define the If you accept that the first child-expr traversed is the root expr of this expression, we actually traverse |
Duh, you are absolutely right.
Why, then, does my PR appear to break this? |
The traversal order is |
But I think your changes is correct. |
Thanks Weijie, that makes perfect sense. I think my PR title then covers that case properly as well. I think your
|
An alternative thought would be to add a |
Well, this would really make things easier, mind setting up an issue to discuss this? I thought it was worth discussing before I started making changes. Update: Oh, to do so, it probably should take a |
Resolves #13817 and resolves #13820.
Not completely sure this is the proper resolution but it fixes the issue. This does cause one test to fail so @reswqa I may need your help here. The failing test is this:
Edit: ok, the reason is because
pl.when()
now dives into the left-most arg, whereas it looks like before thepl.all()
from theotherwise
branch populated the names by default. What is supposed to happen?