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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Array dtype AnyValue Series construction #12817

Merged
merged 3 commits into from
Dec 22, 2023

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Nov 30, 2023

Closes #12719.

Observationally the cast from List to Array is (as expected) extremely cheap (eg: a "with_columns" cast of a 25_000_000 x 4 List col to Array only takes 0.0096 secs), so this PR seems to be a simple/minimal way to support Array AnyValues (absent a dedicated micro-optimised path 馃)

This opens up Array usage to additional constructors, such as pl.from_dicts in the linked issue, which otherwise fail.

@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 Nov 30, 2023
@@ -235,6 +235,10 @@ impl Series {
any_values_to_decimal(av, *precision, *scale)?.into_series()
},
DataType::List(inner) => any_values_to_list(av, inner, strict)?.into_series(),
#[cfg(feature = "dtype-array")]
DataType::Array(inner, size) => any_values_to_list(av, inner, strict)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allocate list offsets where we don't have to.

We should add a any_values_to_array. This one can piggy back on any_values to series creation and then store the array in the an arrow fixedsize list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will come back to this; parking in draft for a bit馃憣

@alexander-beedie alexander-beedie marked this pull request as draft December 6, 2023 07:07
@stinodego stinodego changed the title feat(python,rust): support Array dtype AnyValue Series construction feat: Support Array dtype AnyValue Series construction Dec 15, 2023
@ritchie46 ritchie46 marked this pull request as ready for review December 22, 2023 11:29
@ritchie46 ritchie46 merged commit 2e1013e into pola-rs:main Dec 22, 2023
25 checks passed
@alexander-beedie alexander-beedie deleted the feat-anyvalue-array branch December 28, 2023 18:36
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.

pl.from_dicts doesn't support pl.Array in schema parameter
2 participants