()
| 1673 | |
| 1674 | #[test] |
| 1675 | fn case_with_expr_else() -> Result<()> { |
| 1676 | let batch = case_test_batch()?; |
| 1677 | let schema = batch.schema(); |
| 1678 | |
| 1679 | // CASE a WHEN 'foo' THEN 123 WHEN 'bar' THEN 456 ELSE 999 END |
| 1680 | let when1 = lit("foo"); |
| 1681 | let then1 = lit(123i32); |
| 1682 | let when2 = lit("bar"); |
| 1683 | let then2 = lit(456i32); |
| 1684 | let else_value = lit(999i32); |
| 1685 | |
| 1686 | let expr = generate_case_when_with_type_coercion( |
| 1687 | Some(col("a", &schema)?), |
| 1688 | vec![(when1, then1), (when2, then2)], |
| 1689 | Some(else_value), |
| 1690 | schema.as_ref(), |
| 1691 | )?; |
| 1692 | let result = expr |
| 1693 | .evaluate(&batch)? |
| 1694 | .into_array(batch.num_rows()) |
| 1695 | .expect("Failed to convert to array"); |
| 1696 | let result = as_int32_array(&result)?; |
| 1697 | |
| 1698 | let expected = |
| 1699 | &Int32Array::from(vec![Some(123), Some(999), Some(999), Some(456)]); |
| 1700 | |
| 1701 | assert_eq!(expected, result); |
| 1702 | |
| 1703 | Ok(()) |
| 1704 | } |
| 1705 | |
| 1706 | #[test] |
| 1707 | fn case_with_expr_divide_by_zero() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…