()
| 1485 | |
| 1486 | #[test] |
| 1487 | fn case_with_expr() -> Result<()> { |
| 1488 | let batch = case_test_batch()?; |
| 1489 | let schema = batch.schema(); |
| 1490 | |
| 1491 | // CASE a WHEN 'foo' THEN 123 WHEN 'bar' THEN 456 END |
| 1492 | let when1 = lit("foo"); |
| 1493 | let then1 = lit(123i32); |
| 1494 | let when2 = lit("bar"); |
| 1495 | let then2 = lit(456i32); |
| 1496 | |
| 1497 | let expr = generate_case_when_with_type_coercion( |
| 1498 | Some(col("a", &schema)?), |
| 1499 | vec![(when1, then1), (when2, then2)], |
| 1500 | None, |
| 1501 | schema.as_ref(), |
| 1502 | )?; |
| 1503 | let result = expr |
| 1504 | .evaluate(&batch)? |
| 1505 | .into_array(batch.num_rows()) |
| 1506 | .expect("Failed to convert to array"); |
| 1507 | let result = as_int32_array(&result)?; |
| 1508 | |
| 1509 | let expected = &Int32Array::from(vec![Some(123), None, None, Some(456)]); |
| 1510 | |
| 1511 | assert_eq!(expected, result); |
| 1512 | |
| 1513 | Ok(()) |
| 1514 | } |
| 1515 | |
| 1516 | #[test] |
| 1517 | fn case_with_expr_dictionary() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…