Skip to content

Commit

Permalink
fix scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Jan 8, 2025
1 parent de9b99a commit 0abe2df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/polars-expr/src/expressions/sortby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,17 @@ impl PhysicalExpr for SortByExpr {
})?;

if column.len() == 1 && broadcast_length != 1 {
polars_ensure!(
e.is_scalar(),
ShapeMismatch: "non-scalar expression produces broadcasting column",
);

return Ok(column.new_from_index(0, broadcast_length));
}

if broadcast_length != column.len() {
polars_ensure!(
broadcast_length == 1 && e.is_scalar(),
expr = self.expr, ShapeMismatch:
broadcast_length == 1, ShapeMismatch:
"`sort_by` produced different length ({}) than earlier Series' length in `by` ({})",
broadcast_length, column.len()
);
Expand Down

0 comments on commit 0abe2df

Please sign in to comment.