()
| 1740 | |
| 1741 | #[test] |
| 1742 | fn case_without_expr() -> Result<()> { |
| 1743 | let batch = case_test_batch()?; |
| 1744 | let schema = batch.schema(); |
| 1745 | |
| 1746 | // CASE WHEN a = 'foo' THEN 123 WHEN a = 'bar' THEN 456 END |
| 1747 | let when1 = binary( |
| 1748 | col("a", &schema)?, |
| 1749 | Operator::Eq, |
| 1750 | lit("foo"), |
| 1751 | &batch.schema(), |
| 1752 | )?; |
| 1753 | let then1 = lit(123i32); |
| 1754 | let when2 = binary( |
| 1755 | col("a", &schema)?, |
| 1756 | Operator::Eq, |
| 1757 | lit("bar"), |
| 1758 | &batch.schema(), |
| 1759 | )?; |
| 1760 | let then2 = lit(456i32); |
| 1761 | |
| 1762 | let expr = generate_case_when_with_type_coercion( |
| 1763 | None, |
| 1764 | vec![(when1, then1), (when2, then2)], |
| 1765 | None, |
| 1766 | schema.as_ref(), |
| 1767 | )?; |
| 1768 | let result = expr |
| 1769 | .evaluate(&batch)? |
| 1770 | .into_array(batch.num_rows()) |
| 1771 | .expect("Failed to convert to array"); |
| 1772 | let result = as_int32_array(&result)?; |
| 1773 | |
| 1774 | let expected = &Int32Array::from(vec![Some(123), None, None, Some(456)]); |
| 1775 | |
| 1776 | assert_eq!(expected, result); |
| 1777 | |
| 1778 | Ok(()) |
| 1779 | } |
| 1780 | |
| 1781 | #[test] |
| 1782 | fn case_with_expr_when_null() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…