(
ecx: &ExprContext,
expr: &Expr<Aug>,
field: &Ident,
)
| 4295 | } |
| 4296 | |
| 4297 | fn plan_field_access( |
| 4298 | ecx: &ExprContext, |
| 4299 | expr: &Expr<Aug>, |
| 4300 | field: &Ident, |
| 4301 | ) -> Result<CoercibleScalarExpr, PlanError> { |
| 4302 | let field = normalize::column_name(field.clone()); |
| 4303 | let expr = plan_expr(ecx, expr)?.type_as_any(ecx)?; |
| 4304 | let ty = ecx.scalar_type(&expr); |
| 4305 | let i = match &ty { |
| 4306 | SqlScalarType::Record { fields, .. } => { |
| 4307 | fields.iter().position(|(name, _ty)| *name == field) |
| 4308 | } |
| 4309 | ty => sql_bail!( |
| 4310 | "column notation applied to type {}, which is not a composite type", |
| 4311 | ecx.humanize_sql_scalar_type(ty, false) |
| 4312 | ), |
| 4313 | }; |
| 4314 | match i { |
| 4315 | None => sql_bail!( |
| 4316 | "field {} not found in data type {}", |
| 4317 | field, |
| 4318 | ecx.humanize_sql_scalar_type(&ty, false) |
| 4319 | ), |
| 4320 | Some(i) => Ok(expr |
| 4321 | .call_unary(UnaryFunc::RecordGet(expr_func::RecordGet(i))) |
| 4322 | .into()), |
| 4323 | } |
| 4324 | } |
| 4325 | |
| 4326 | fn plan_subscript( |
| 4327 | ecx: &ExprContext, |
no test coverage detected