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

Function plan_list

src/sql/src/plan/query.rs:5018–5053  ·  view source on GitHub ↗
(
    ecx: &ExprContext,
    exprs: &[Expr<Aug>],
    type_hint: Option<&SqlScalarType>,
)

Source from the content-addressed store, hash-verified

5016}
5017
5018fn plan_list(
5019 ecx: &ExprContext,
5020 exprs: &[Expr<Aug>],
5021 type_hint: Option<&SqlScalarType>,
5022) -> Result<CoercibleScalarExpr, PlanError> {
5023 let (elem_type, exprs) = if exprs.is_empty() {
5024 if let Some(SqlScalarType::List { element_type, .. }) = type_hint {
5025 (element_type.without_modifiers(), vec![])
5026 } else {
5027 sql_bail!("cannot determine type of empty list");
5028 }
5029 } else {
5030 let type_hint = match type_hint {
5031 Some(SqlScalarType::List { element_type, .. }) => Some(&**element_type),
5032 _ => None,
5033 };
5034
5035 let mut out = vec![];
5036 for expr in exprs {
5037 out.push(match expr {
5038 // Special case nested LIST expressions so we can plumb
5039 // the type hint through.
5040 Expr::List(exprs) => plan_list(ecx, exprs, type_hint)?,
5041 _ => plan_expr(ecx, expr)?,
5042 });
5043 }
5044 let out = coerce_homogeneous_exprs(&ecx.with_name("LIST"), out, type_hint)?;
5045 (ecx.scalar_type(&out[0]).without_modifiers(), out)
5046 };
5047
5048 if matches!(elem_type, SqlScalarType::Char { .. }) {
5049 bail_unsupported!("char list");
5050 }
5051
5052 Ok(HirScalarExpr::call_variadic(ListCreate { elem_type }, exprs).into())
5053}
5054
5055fn plan_map(
5056 ecx: &ExprContext,

Callers 2

plan_expr_innerFunction · 0.85
plan_castFunction · 0.85

Calls 7

plan_exprFunction · 0.85
coerce_homogeneous_exprsFunction · 0.85
without_modifiersMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45
with_nameMethod · 0.45
scalar_typeMethod · 0.45

Tested by

no test coverage detected