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

alamb pushed a commit to branch 59_maintenance
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/59_maintenance by this push:
     new e4e1237feb [59_maintenance] Backport fix for concat_run_arrays with 
all-empty run arrays (#10828)
e4e1237feb is described below

commit e4e1237feb74ac8af3ee42f0026d0a55daf90dad
Author: Andrew Lamb <[email protected]>
AuthorDate: Tue Aug 25 05:49:31 2026 -0400

    [59_maintenance] Backport fix for concat_run_arrays with all-empty run 
arrays (#10828)
    
    # Which issue does this PR close?
    
    - part of https://github.com/apache/arrow-rs/issues/10738
    
    # Rationale for this change
    
    Backport the fix for `concat_run_arrays` erroring when every input
    RunArray has empty run_ends
    (https://github.com/apache/arrow-rs/issues/10781) to the
    `59_maintenance` branch so it is included in the 59.3.0 release.
    
    # What changes are included in this PR?
    
    Backport / Cherry-pick:
    - https://github.com/apache/arrow-rs/pull/10782
    
    # Are these changes tested?
    
    By CI
    
    # Are there any user-facing changes?
    
    No
    
    Co-authored-by: Thor <[email protected]>
    Co-authored-by: Jeffrey Vo <[email protected]>
---
 arrow-select/src/concat.rs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arrow-select/src/concat.rs b/arrow-select/src/concat.rs
index f18624c5ad..1587ef6d4f 100644
--- a/arrow-select/src/concat.rs
+++ b/arrow-select/src/concat.rs
@@ -424,6 +424,12 @@ where
         .filter(|x| !x.run_ends().is_empty())
         .collect();
 
+    if run_arrays.is_empty() {
+        // If all input arrays are empty then handle here otherwise we
+        // lose the type below
+        return Ok(new_empty_array(arrays[0].data_type()));
+    }
+
     // The run ends need to be adjusted by the sum of the lengths of the 
previous arrays.
     let needed_run_end_adjustments = std::iter::once(R::default_value())
         .chain(
@@ -1864,6 +1870,24 @@ mod tests {
         assert_eq!(expected, actual);
     }
 
+    #[test]
+    fn test_concat_run_array_all_empty() {
+        let run_ends1 = Int32Array::from(vec![2, 4]);
+        let values1 = Int32Array::from(vec![10, 20]);
+        let array1 = RunArray::try_new(&run_ends1, &values1).unwrap();
+        let array1 = array1.slice(0, 0);
+
+        let run_ends2 = Int32Array::from(vec![1, 4]);
+        let values2 = Int32Array::from(vec![30, 40]);
+        let array2 = RunArray::try_new(&run_ends2, &values2).unwrap();
+        let array2 = array2.slice(0, 0);
+
+        let result = concat(&[&array1, &array2]).unwrap();
+        let result_run_array: &arrow_array::RunArray<Int32Type> = 
result.as_run();
+        assert_eq!(result_run_array.len(), 0);
+        assert_eq!(result_run_array.data_type(), array1.data_type());
+    }
+
     #[test]
     fn test_concat_run_array_matching_first_last_value() {
         // Create a run array with run ends [2, 4, 7] and values [10, 20, 30]

Reply via email to