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

Function plan_subscript_list

src/sql/src/plan/query.rs:4412–4459  ·  view source on GitHub ↗
(
    ecx: &ExprContext,
    mut expr: HirScalarExpr,
    positions: &[SubscriptPosition<Aug>],
    mut remaining_layers: usize,
    elem_type_name: &str,
)

Source from the content-addressed store, hash-verified

4410}
4411
4412fn plan_subscript_list(
4413 ecx: &ExprContext,
4414 mut expr: HirScalarExpr,
4415 positions: &[SubscriptPosition<Aug>],
4416 mut remaining_layers: usize,
4417 elem_type_name: &str,
4418) -> Result<CoercibleScalarExpr, PlanError> {
4419 let mut i = 0;
4420
4421 while i < positions.len() {
4422 // Take all contiguous index operations, i.e. find next slice operation.
4423 let j = positions[i..]
4424 .iter()
4425 .position(|p| p.explicit_slice)
4426 .unwrap_or(positions.len() - i);
4427 if j != 0 {
4428 let indexes = extract_scalar_subscript_from_positions(&positions[i..i + j], "")?;
4429 let (n, e) = plan_index_list(
4430 ecx,
4431 expr,
4432 indexes.as_slice(),
4433 remaining_layers,
4434 elem_type_name,
4435 )?;
4436 remaining_layers = n;
4437 expr = e;
4438 i += j;
4439 }
4440
4441 // Take all contiguous slice operations, i.e. find next index operation.
4442 let j = positions[i..]
4443 .iter()
4444 .position(|p| !p.explicit_slice)
4445 .unwrap_or(positions.len() - i);
4446 if j != 0 {
4447 expr = plan_slice_list(
4448 ecx,
4449 expr,
4450 &positions[i..i + j],
4451 remaining_layers,
4452 elem_type_name,
4453 )?;
4454 i += j;
4455 }
4456 }
4457
4458 Ok(expr.into())
4459}
4460
4461fn plan_index_list(
4462 ecx: &ExprContext,

Callers 1

plan_subscriptFunction · 0.85

Calls 7

plan_index_listFunction · 0.85
plan_slice_listFunction · 0.85
as_sliceMethod · 0.80
lenMethod · 0.45
positionMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected