MCPcopy Create free account
hub / github.com/apache/datafusion / binary_comparison

Function binary_comparison

datafusion/physical-expr/src/expressions/binary.rs:1028–1060  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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<()> {

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
binaryFunction · 0.85
as_boolean_arrayFunction · 0.85
colFunction · 0.70
into_arrayMethod · 0.45
evaluateMethod · 0.45
takeMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…