From e0e17e7e25ea02eb01253d439c834285201855c3 Mon Sep 17 00:00:00 2001 From: cmdlineluser <99486669+cmdlineluser@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:11:04 +0100 Subject: [PATCH] return expected struct error and remove unneeded assignment/unwrapping --- .../polars-plan/src/dsl/function_expr/schema.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/polars/polars-lazy/polars-plan/src/dsl/function_expr/schema.rs b/polars/polars-lazy/polars-plan/src/dsl/function_expr/schema.rs index 492272f0cb44..82dd321fd853 100644 --- a/polars/polars-lazy/polars-plan/src/dsl/function_expr/schema.rs +++ b/polars/polars-lazy/polars-plan/src/dsl/function_expr/schema.rs @@ -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) => {