Skip to content

Commit

Permalink
throw error on invalid map expressions (#2664)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 16, 2022
1 parent 7f17f3a commit 0b164d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions polars/polars-lazy/src/physical_plan/expressions/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ impl PhysicalExpr for ApplyExpr {
Ok(ac)
}
ApplyOptions::ApplyFlat => {
let s = self
.function
.call_udf(&mut [ac.flat_naive().into_owned()])?;
let input = ac.flat_naive().into_owned();
let input_len = input.len();
let s = self.function.call_udf(&mut [input])?;

if s.len() != input_len {
return Err(PolarsError::ComputeError("A map function may never return a Series of a different length than its input".into()));
}

if ac.is_aggregated() {
ac.with_update_groups(UpdateGroups::WithGroupsLen);
}
Expand Down

0 comments on commit 0b164d4

Please sign in to comment.