(
ecx: &ExprContext,
expr: HirScalarExpr,
indexes: &[&Expr<Aug>],
n_layers: usize,
elem_type_name: &str,
)
| 4459 | } |
| 4460 | |
| 4461 | fn plan_index_list( |
| 4462 | ecx: &ExprContext, |
| 4463 | expr: HirScalarExpr, |
| 4464 | indexes: &[&Expr<Aug>], |
| 4465 | n_layers: usize, |
| 4466 | elem_type_name: &str, |
| 4467 | ) -> Result<(usize, HirScalarExpr), PlanError> { |
| 4468 | let depth = indexes.len(); |
| 4469 | |
| 4470 | if depth > n_layers { |
| 4471 | if n_layers == 0 { |
| 4472 | sql_bail!("cannot subscript type {}", elem_type_name) |
| 4473 | } else { |
| 4474 | sql_bail!( |
| 4475 | "cannot index into {} layers; list only has {} layer{}", |
| 4476 | depth, |
| 4477 | n_layers, |
| 4478 | if n_layers == 1 { "" } else { "s" } |
| 4479 | ) |
| 4480 | } |
| 4481 | } |
| 4482 | |
| 4483 | let mut exprs = Vec::with_capacity(depth + 1); |
| 4484 | exprs.push(expr); |
| 4485 | |
| 4486 | for i in indexes { |
| 4487 | exprs.push(plan_expr(ecx, i)?.cast_to( |
| 4488 | ecx, |
| 4489 | CastContext::Explicit, |
| 4490 | &SqlScalarType::Int64, |
| 4491 | )?); |
| 4492 | } |
| 4493 | |
| 4494 | Ok(( |
| 4495 | n_layers - depth, |
| 4496 | HirScalarExpr::call_variadic(ListIndex, exprs), |
| 4497 | )) |
| 4498 | } |
| 4499 | |
| 4500 | fn plan_slice_list( |
| 4501 | ecx: &ExprContext, |
no test coverage detected