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

fix: Fix incorrect lazy schema for explode() in agg() #19623

Closed
wants to merge 4 commits into from

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Nov 4, 2024

Fixes #19562

nvm, I have a better fix in newer PR. This one is more of a hack

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Nov 4, 2024
@@ -170,7 +170,7 @@ impl ApplyExpr {
// })?
let out: ListChunked = POOL.install(|| iter.collect::<PolarsResult<_>>())?;

debug_assert_eq!(out.dtype(), &DataType::List(Box::new(dtype)));
debug_assert_eq!(&dtype, out.dtype());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the output field of the expression should created in an aggregation-context-aware manner, so I've updated this assertion.

@@ -239,7 +239,7 @@ fn create_physical_expr_inner(
// TODO! Order by
let group_by = create_physical_expressions_from_nodes(
partition_by,
Context::Default,
Context::Aggregation,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is under AExpr::Window

@@ -72,7 +72,6 @@ impl AExpr {
},
Explode(expr) => {
let field = arena.get(*expr).to_field_impl(schema, arena, nested)?;
*nested = nested.saturating_sub(1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix for the linked issue explode()

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.92%. Comparing base (0f64785) to head (6c883d0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19623      +/-   ##
==========================================
- Coverage   79.92%   79.92%   -0.01%     
==========================================
  Files        1536     1536              
  Lines      211686   211695       +9     
  Branches     2445     2445              
==========================================
+ Hits       169192   169197       +5     
- Misses      41939    41943       +4     
  Partials      555      555              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

expr_arena
.get(expression)
.to_field(schema, Context::Default, expr_arena)?;
if let Context::Aggregation = ctxt {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just pass the context to line 497 instead of updating the dtype here.

expr_arena
.get(expression)
.to_field(schema, Context::Default, expr_arena)?;
if let Context::Aggregation = ctxt {
Copy link
Member

Choose a reason for hiding this comment

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

idem

@nameexhaustion nameexhaustion marked this pull request as draft November 5, 2024 05:37
@nameexhaustion nameexhaustion added do not merge This pull requests should not be merged right now reference Reference issue for recurring topics labels Nov 5, 2024
@nameexhaustion
Copy link
Collaborator Author

I think I have this figured out, will close in favor of #19629

@nameexhaustion nameexhaustion deleted the agg-field-dtype branch November 18, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge This pull requests should not be merged right now fix Bug fix python Related to Python Polars reference Reference issue for recurring topics rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LazyFrame has incorrect schema following aggregation of an exploded list column expression
2 participants