Skip to content

Commit

Permalink
return expected struct error and remove unneeded assignment/unwrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdlineluser committed Jul 27, 2023
1 parent 2000d22 commit e0e17e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions polars/polars-lazy/polars-plan/src/dsl/function_expr/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ impl FunctionExpr {
FieldByIndex(index) => {
let (index, _) = slice_offsets(*index, 0, fields.len());
if let DataType::Struct(flds) = &fields[0].dtype {
let fld = flds.get(index).cloned().ok_or_else(
|| polars_err!(ComputeError: "index out of bounds in `struct.field`")
)?;
Ok(fld)
flds.get(index).cloned().ok_or_else(
|| polars_err!(ComputeError: "index out of bounds in `struct.field`")
)
} else {
polars_bail!(ComputeError: "index out of bounds in `struct.field`");
polars_bail!(
ComputeError: "expected struct dtype, got: `{}`", &fields[0].dtype
)
}
}
FieldByName(name) => {
Expand Down

0 comments on commit e0e17e7

Please sign in to comment.