`binary_mut` and `try_binary_mut` return `Ok` for an empty array whose buffer is shared

Abierto
#12,002 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #12012 de @abhinav-phi — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
data

Línea de trabajo

Read arrow-arith/src/arity.rs around binary_mut and try_binary_mut, then compare their empty-array early returns with into_builder in arrow-array/src/array/primitive_array.rs and the unary helpers. First resolve which shared-buffer behavior the binary forms should follow; done means their behavior and rustdoc agree, with regression coverage for the empty shared-buffer case.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

The rustdoc of binary_mut says that if the buffer of a is shared, it returns Err(self), and try_binary_mut refers to it for buffer reuse. For an empty a, both return Ok(Ok(empty array)) even when the buffer is shared, because they return early before into_builder (the same in try_binary_mut). unary_mut and try_unary_mut call into_builder first, so they return Err(self) for the same input.

No buffer is changed, so this is a difference between the documentation and the behavior, and between the unary and binary forms.

To Reproduce

On main at 9ffd63d528:

use arrow::array::Int32Array;
use arrow::compute::{binary_mut, try_binary_mut, try_unary_mut, unary_mut};

let a = Int32Array::from(Vec::<i32>::new());
let b = Int32Array::from(Vec::<i32>::new());

// Err(self): the buffer is shared with `a`
assert!(unary_mut(a.clone(), |x| x + 1).is_err());
assert!(try_unary_mut(a.clone(), |x| Ok(x + 1)).is_err());

// Ok(Ok(empty)) instead of Err(self)
assert!(matches!(binary_mut(a.clone(), &b, |x, y| x + y), Ok(Ok(_))));
assert!(matches!(try_binary_mut(a.clone(), &b, |x, y| Ok(x + y)), Ok(Ok(_))));

Expected behavior

Should the binary forms return Err(self) for a shared buffer whatever its length, as the rustdoc says and the unary forms do? Or should all four return Ok for an empty array, and the rustdoc say so?

Additional context

Found by a property test of the arity helpers.

Lenguaje dominante
Rust
Estrellas
3.7k
Forks
1.5k
Merge medio
2 d 16 h
PR fusionados (30 d)
183

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/arrow-rs

Todos los issues de apache/arrow-rs

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.