arrow/compute: safe float to integer cast skips the truncation check in sliced arrays with nulls
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 1/100
Línea de trabajo
Read arrow/compute/internal/kernels/numeric_cast.go, especially checkFloatTrunc, and compare its bitmap lookup with the offset handling in helpers.go. The issue includes sliced-array examples that reproduce both incorrect outcomes; use them to check the behavior. Done means safe casts report truncation for fractional valid values and ignore values stored under nulls. A linked pull request is already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug, including details regarding any error messages, version, and platform.
A safe cast (compute.SafeCastOptions) from a float array to an integer type reads the validity bitmap at the wrong position when the input is a slice and a block contains nulls. A fractional value can be truncated without an error:
bldr := array.NewFloat64Builder(memory.DefaultAllocator)
bldr.AppendValues([]float64{0, 1.5, 2, 0}, []bool{false, true, true, false})
arr := bldr.NewArray()
s := array.NewSlice(arr, 1, 4) // [1.5 2 (null)]
out, err := compute.CastArray(context.Background(), s, compute.SafeCastOptions(arrow.PrimitiveTypes.Int32))
fmt.Println(out, err) // [1 2 (null)] <nil>
Expected: float value 1.500000 was truncated converting to int32, which is what the same values give unsliced.
It also fails the other way. If a null slot inside the slice stores a fractional value ([0, 1.5, 2, 9.5, 7.5] with index 0 and 3 null, sliced [2:4] = [2 (null)]), the cast fails because it checks the 9.5 under the null.
Cause: checkFloatTrunc in arrow/compute/internal/kernels/numeric_cast.go starts offsetPos at 0, then calls bitutil.BitIsSet(bitmap, int(offsetPos)+i). The block counter and the value slices already account for in.Offset, so the bitmap lookup is shifted by the slice offset. The integer bounds check in helpers.go starts at data.Offset.
main at e96596d, Go 1.26.4, darwin/arm64. The code path doesn't depend on the platform.
I have a fix with a test and will open a PR.
Component(s)
Other
- Lenguaje dominante
- Assembly
- Estrellas
- 423
- Forks
- 188
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 164
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/arrow-go
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
apache/arrow-go#1591 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Type: bug
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
parquet/file: a panic recovered in WriteBatch is not kept, so Close writes a footer for rows with no valuesPosiblemente ocupada @EdwardShen125 la tomó hace 5 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
ipc: stream reader accepts an invalid flatbuffer schema and decimal precision 0Posiblemente ocupada @AynSiddiqui la tomó hace 7 días. Abierto
apache/arrow-go#1676 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/arrow-go
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
epiforecasts/EpiNow2#1694 · 2 reacciones ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
component/core domain/framework
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitwarden/directory-connector#1303 · 1 comentario ·
Los mantenedores suelen responder en 1 día