(func: &VariadicFunc, args: &[ReprColumnType])
| 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) |
no test coverage detected