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

Function variadic_typecheck

src/expr/src/interpret.rs:1369–1387  ·  view source on GitHub ↗
(func: &VariadicFunc, args: &[ReprColumnType])

Source from the content-addressed store, hash-verified

1367 };
1368
1369 fn variadic_typecheck(func: &VariadicFunc, args: &[ReprColumnType]) -> bool {
1370 use VariadicFunc::*;
1371 fn all_eq<'a>(
1372 iter: impl IntoIterator<Item = &'a ReprColumnType>,
1373 other: &ReprScalarType,
1374 ) -> bool {
1375 iter.into_iter().all(|t| t.scalar_type == *other)
1376 }
1377 match func {
1378 Coalesce(_) | Greatest(_) | Least(_) => match args {
1379 [] => true,
1380 [first, rest @ ..] => all_eq(rest, &first.scalar_type),
1381 },
1382 And(_) | Or(_) => all_eq(args, &ReprScalarType::Bool),
1383 Concat(_) => all_eq(args, &ReprScalarType::String),
1384 ConcatWs(_) => args.len() > 1 && all_eq(args, &ReprScalarType::String),
1385 _ => false,
1386 }
1387 }
1388
1389 fn gen_datums_for_type(typ: &ReprColumnType) -> BoxedStrategy<Datum<'static>> {
1390 let mut values: Vec<Datum<'static>> = SqlScalarType::from_repr(&typ.scalar_type)

Callers 1

gen_expr_for_relationFunction · 0.85

Calls 2

all_eqFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected