MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan_index_list

Function plan_index_list

src/sql/src/plan/query.rs:4461–4498  ·  view source on GitHub ↗
(
    ecx: &ExprContext,
    expr: HirScalarExpr,
    indexes: &[&Expr<Aug>],
    n_layers: usize,
    elem_type_name: &str,
)

Source from the content-addressed store, hash-verified

4459}
4460
4461fn 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
4500fn plan_slice_list(
4501 ecx: &ExprContext,

Callers 1

plan_subscript_listFunction · 0.85

Calls 4

plan_exprFunction · 0.85
cast_toMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected