This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 3a39ef2339 Add simple unit test for `merge` in case expression (#18369)
3a39ef2339 is described below

commit 3a39ef2339e6d343016155a9b8a128ff1080e1c6
Author: Pepijn Van Eeckhoudt <[email protected]>
AuthorDate: Thu Oct 30 12:29:04 2025 +0100

    Add simple unit test for `merge` in case expression (#18369)
    
    ## Which issue does this PR close?
    
    - None, followup for #18152
    
    ## Rationale for this change
    
    Add a unit test testing (and demonstrating) the merge function.
    
    ## What changes are included in this PR?
    
    Adds an additional test case
    
    ## Are these changes tested?
    
    Who tests the tests?
    
    ## Are there any user-facing changes?
    
    No
---
 datafusion/physical-expr/src/expressions/case.rs | 31 ++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/datafusion/physical-expr/src/expressions/case.rs 
b/datafusion/physical-expr/src/expressions/case.rs
index 0b4c3af1d9..d58b038424 100644
--- a/datafusion/physical-expr/src/expressions/case.rs
+++ b/datafusion/physical-expr/src/expressions/case.rs
@@ -1954,4 +1954,35 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn test_merge() {
+        let a1 = StringArray::from(vec![Some("A")]).to_data();
+        let a2 = StringArray::from(vec![Some("B")]).to_data();
+        let a3 = StringArray::from(vec![Some("C"), Some("D")]).to_data();
+
+        let indices = vec![
+            PartialResultIndex::none(),
+            PartialResultIndex::try_new(1).unwrap(),
+            PartialResultIndex::try_new(0).unwrap(),
+            PartialResultIndex::none(),
+            PartialResultIndex::try_new(2).unwrap(),
+            PartialResultIndex::try_new(2).unwrap(),
+        ];
+
+        let merged = merge(&vec![a1, a2, a3], &indices).unwrap();
+        let merged = merged.as_string::<i32>();
+
+        assert_eq!(merged.len(), indices.len());
+        assert!(!merged.is_valid(0));
+        assert!(merged.is_valid(1));
+        assert_eq!(merged.value(1), "B");
+        assert!(merged.is_valid(2));
+        assert_eq!(merged.value(2), "A");
+        assert!(!merged.is_valid(3));
+        assert!(merged.is_valid(4));
+        assert_eq!(merged.value(4), "C");
+        assert!(merged.is_valid(5));
+        assert_eq!(merged.value(5), "D");
+    }
 }


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

Reply via email to