FreakingMind opened a new issue, #7596:
URL: https://github.com/apache/datafusion-comet/issues/7596

   `MergeRowsStream` builds the "not matched" masks with 
`arrow::compute::kernels::boolean::and_not` (`merge_rows.rs:625-626`). In arrow 
59.x `and_not` mixes up the offsets of its inputs when one of them is a slice 
(apache/arrow-rs#10698, fixed in apache/arrow-rs#10699 for 60.0.0, not 
backported). Comet main resolves arrow to 59.3.2, so the bug is still there.
   
   After the full outer join one marker column can be a slice with a non-zero 
offset. Then the task either panics with `offset + len out of bounds`, or gets 
wrong masks with no error and applies inserts and deletes to the wrong rows. We 
hit the panic on Iceberg MERGE with `spark.comet.exec.mergeRows.enabled=true` 
(Comet 1.2.0, Spark 4.0.2); with the flag off the jobs pass.
   
   ```rust
   // arrow = "=59.3.2"
   use arrow::array::{Array, BooleanArray};
   use arrow::compute::kernels::boolean::{and, and_not, not};
   
   fn mask(len: usize, f: fn(usize) -> bool) -> BooleanArray {
       BooleanArray::from((0..len).map(f).collect::<Vec<_>>())
   }
   
   fn main() {
       let left = mask(3000, |i| i % 3 != 0).slice(0, 1000);
       let right = mask(2000, |i| i % 5 == 0).slice(1000, 1000);
       let expected = and(&left, &not(&right).unwrap()).unwrap();
       let actual = and_not(&left, &right).unwrap();
       let wrong = (0..1000).filter(|&i| actual.value(i) != 
expected.value(i)).count();
       println!("wrong values: {wrong} of 1000"); // 59.x: 533, 60.1: 0
   }
   ```
   
   Until Comet moves to arrow 60 (#7249), replacing the two calls with `and(a, 
&not(b)?)` fixes it.
   


-- 
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