gabotechs commented on code in PR #21764:
URL: https://github.com/apache/datafusion/pull/21764#discussion_r3129460955


##########
datafusion/functions/src/core/nullif.rs:
##########
@@ -251,6 +260,88 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn nullif_struct() -> Result<()> {
+        let fields = Fields::from(vec![
+            Field::new("a", DataType::Int64, true),
+            Field::new("b", DataType::Utf8, true),
+        ]);
+
+        let lhs_a = Arc::new(Int64Array::from(vec![Some(1), Some(2), None]));
+        let lhs_b = Arc::new(StringArray::from(vec![Some("1"), Some("2"), 
None]));
+        let lhs_nulls = Some(NullBuffer::from(vec![true, true, false]));
+        let lhs = ColumnarValue::Array(Arc::new(StructArray::new(
+            fields.clone(),
+            vec![lhs_a, lhs_b],
+            lhs_nulls,
+        )));
+
+        let rhs_a = Arc::new(Int64Array::from(vec![Some(1), Some(9), None]));
+        let rhs_b = Arc::new(StringArray::from(vec![Some("1"), Some("2"), 
None]));
+        let rhs_nulls = Some(NullBuffer::from(vec![true, true, false]));
+        let rhs = ColumnarValue::Array(Arc::new(StructArray::new(
+            fields,
+            vec![rhs_a, rhs_b],
+            rhs_nulls,
+        )));
+
+        let result = nullif_func(&[lhs, rhs])?;
+        let result = result.into_array(0).expect("Failed to convert to array");
+        let batch = RecordBatch::try_from_iter([("result", result)])?;
+
+        let expected = [
+            "+--------------+",
+            "| result       |",
+            "+--------------+",
+            "|              |",
+            "| {a: 2, b: 2} |",
+            "|              |",
+            "+--------------+",
+        ];
+
+        assert_batches_eq!(expected, &[batch]);
+
+        Ok(())

Review Comment:
   I'd try to be consistent with the other tests in this file and, rather than 
asserting a string representation of the record batches, I'd try to perform 
assertions of the returned `ArrayRef`s.
   
   If you think it's strictly necessary to perform assertions over 
pretty-printed string representations, this project typically uses `insta` for 
managing them.



##########
datafusion/functions/Cargo.toml:
##########
@@ -78,6 +78,7 @@ datafusion-execution = { workspace = true }
 datafusion-expr = { workspace = true }
 datafusion-expr-common = { workspace = true }
 datafusion-macros = { workspace = true }
+datafusion-physical-expr-common = { workspace = true }

Review Comment:
   🤔 I don't see a problem in introducing this coupling point here, but I'll 
double check if this is fine.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to