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

Function test_reduce

src/expr/src/scalar.rs:2480–2554  ·  view source on GitHub ↗

error: unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`

()

Source from the content-addressed store, hash-verified

2478 #[mz_ore::test]
2479 #[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`
2480 fn test_reduce() {
2481 let relation_type: Vec<ReprColumnType> = vec![
2482 ReprScalarType::Int64.nullable(true),
2483 ReprScalarType::Int64.nullable(true),
2484 ReprScalarType::Int64.nullable(false),
2485 ]
2486 .into_iter()
2487 .collect();
2488 let col = MirScalarExpr::column;
2489 let int64_typ = ReprScalarType::Int64;
2490 let err = |e| MirScalarExpr::literal(Err(e), int64_typ.clone());
2491 let lit = |i| MirScalarExpr::literal_ok(Datum::Int64(i), int64_typ.clone());
2492 let null = || MirScalarExpr::literal_null(int64_typ.clone());
2493
2494 struct TestCase {
2495 input: MirScalarExpr,
2496 output: MirScalarExpr,
2497 }
2498
2499 let test_cases = vec![
2500 TestCase {
2501 input: MirScalarExpr::call_variadic(Coalesce, vec![lit(1)]),
2502 output: lit(1),
2503 },
2504 TestCase {
2505 input: MirScalarExpr::call_variadic(Coalesce, vec![lit(1), lit(2)]),
2506 output: lit(1),
2507 },
2508 TestCase {
2509 input: MirScalarExpr::call_variadic(Coalesce, vec![null(), lit(2), null()]),
2510 output: lit(2),
2511 },
2512 TestCase {
2513 input: MirScalarExpr::call_variadic(
2514 Coalesce,
2515 vec![null(), col(0), null(), col(1), lit(2), lit(3)],
2516 ),
2517 output: MirScalarExpr::call_variadic(Coalesce, vec![col(0), col(1), lit(2)]),
2518 },
2519 TestCase {
2520 input: MirScalarExpr::call_variadic(Coalesce, vec![col(0), col(2), col(1)]),
2521 output: MirScalarExpr::call_variadic(Coalesce, vec![col(0), col(2)]),
2522 },
2523 TestCase {
2524 input: MirScalarExpr::call_variadic(
2525 Coalesce,
2526 vec![lit(1), err(EvalError::DivisionByZero)],
2527 ),
2528 output: lit(1),
2529 },
2530 TestCase {
2531 input: MirScalarExpr::call_variadic(
2532 Coalesce,
2533 vec![
2534 null(),
2535 err(EvalError::DivisionByZero),
2536 err(EvalError::NumericFieldOverflow),
2537 ],

Callers

nothing calls this directly

Calls 4

collectMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45
reduceMethod · 0.45

Tested by

no test coverage detected