-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Regression 0.20.15->0.20.16: ComputeError: conversion from null
to struct[100]
failed in column 'literal' for 0 out of 1 values
#15476
Comments
Can reproduce the error. On df1 = pl.DataFrame({
"a": [1, 2, 3, 4, 5],
"b": [[{"a": 1}], [{"a": 1}, {"a": 2}], [{"a": 1}, {"a": 2}, {"a": 3}], [], None]
})
pl.__version__
df1.with_columns(
pl.when((pl.col("b").is_not_null()) & (pl.col("b").list.len() > 0))
.then(pl.col("b").list.to_struct("max_width", lambda x: f"{x}", 100))
)
# '0.20.15'
# shape: (5, 2)
# ┌─────┬────────────────────────┐
# │ a ┆ b │
# │ --- ┆ --- │
# │ i64 ┆ struct[3] │
# ╞═════╪════════════════════════╡
# │ 1 ┆ {{1},{null},{null}} │
# │ 2 ┆ {{1},{2},{null}} │
# │ 3 ┆ {{1},{2},{3}} │
# │ 4 ┆ {{null},{null},{null}} │
# │ 5 ┆ {{null},{null},{null}} │
# └─────┴────────────────────────┘ Does the df1.with_columns(
pl.col("b").list.to_struct("max_width", lambda x: f"{x}", 100)
)
# shape: (5, 2)
# ┌─────┬────────────────────────┐
# │ a ┆ b │
# │ --- ┆ --- │
# │ i64 ┆ struct[3] │
# ╞═════╪════════════════════════╡
# │ 1 ┆ {{1},{null},{null}} │
# │ 2 ┆ {{1},{2},{null}} │
# │ 3 ┆ {{1},{2},{3}} │
# │ 4 ┆ {{null},{null},{null}} │
# │ 5 ┆ {{null},{null},{null}} │
# └─────┴────────────────────────┘ |
Thanks @antonioalegria and @cmdlineluser. This should have been an issue for some time, but |
After some discussion, I think this should be fixed if we enable outer validity for Until then, you may need to set |
Where should I set type_coercion=False? |
This no longer reproduces. Closing. |
Checks
Reproducible example
Log output
Issue description
In 0.20.15 this ran without any issues, now it raises this exception.
Expected behavior
It should run as in 0.20.15, unless I need to migrate some code, printing the following:
Installed versions
The text was updated successfully, but these errors were encountered: