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

feat(rust, python): add .struct.field() expression expansion #10336

Closed

Conversation

cmdlineluser
Copy link
Contributor

@cmdlineluser cmdlineluser commented Aug 7, 2023

Update: This was a much more complex problem than I realised - sorry for the noise.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Aug 7, 2023
@cmdlineluser
Copy link
Contributor Author

Hmm - yes, so there is quite a bit more to this than it seemed at first look.

pl.col().struct.field("*") is only the simplest form, as schema.get(col) gives you the field names.

However, if we chain some calls, we can see it's rather more complex:

pl.col("foo").struct.field("*").struct.field("*").struct.field("C")

expr.into_iter() yields the following order:

pl.col("foo").struct.field("*").struct.field("*").struct.field("C")
pl.col("foo").struct.field("*").struct.field("*")
pl.col("foo").struct.field("*")
pl.col("foo")

As the parent may be another struct, all ancestors need to be expanded in order to access the field names.

Chains consisting of multiple "*" calls also brings up the topic of name clashing. It seems like a default behaviour of automatically prefixing the "current path" to the returned name would be needed in order to prevent this.

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

Successfully merging this pull request may close these issues.

1 participant