()
| 1026 | |
| 1027 | #[test] |
| 1028 | fn binary_comparison() -> Result<()> { |
| 1029 | let schema = Schema::new(vec![ |
| 1030 | Field::new("a", DataType::Int32, false), |
| 1031 | Field::new("b", DataType::Int32, false), |
| 1032 | ]); |
| 1033 | let a = Int32Array::from(vec![1, 2, 3, 4, 5]); |
| 1034 | let b = Int32Array::from(vec![1, 2, 4, 8, 16]); |
| 1035 | |
| 1036 | // expression: "a < b" |
| 1037 | let lt = binary( |
| 1038 | col("a", &schema)?, |
| 1039 | Operator::Lt, |
| 1040 | col("b", &schema)?, |
| 1041 | &schema, |
| 1042 | )?; |
| 1043 | let batch = |
| 1044 | RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a), Arc::new(b)])?; |
| 1045 | |
| 1046 | let result = lt |
| 1047 | .evaluate(&batch)? |
| 1048 | .into_array(batch.num_rows()) |
| 1049 | .expect("Failed to convert to array"); |
| 1050 | assert_eq!(result.len(), 5); |
| 1051 | |
| 1052 | let expected = [false, false, true, true, true]; |
| 1053 | let result = |
| 1054 | as_boolean_array(&result).expect("failed to downcast to BooleanArray"); |
| 1055 | for (i, &expected_item) in expected.iter().enumerate().take(5) { |
| 1056 | assert_eq!(result.value(i), expected_item); |
| 1057 | } |
| 1058 | |
| 1059 | Ok(()) |
| 1060 | } |
| 1061 | |
| 1062 | #[test] |
| 1063 | fn binary_nested() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…