(
ecx: &ExprContext,
exprs: &[Expr<Aug>],
type_hint: Option<&SqlScalarType>,
)
| 5016 | } |
| 5017 | |
| 5018 | fn 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 | |
| 5055 | fn plan_map( |
| 5056 | ecx: &ExprContext, |
no test coverage detected