[Bug] Python NumpyTablet silently drops trailing zero bytes from BLOB values

Abierto Apto para principiantes
#19,433 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@DaZuiZui ya está trabajando en esto.

Desde el 27/11/2026.

  • #19434 de @DaZuiZui — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
85/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
numpy, python
Área
databases

Línea de trabajo

Lee las implementaciones de NumpyTablet y TSDataType.BLOB.np_dtype() del cliente de Python y, después, revisa la ruta de serialización de BLOB junto con Tablet.get_binary_values(). Reproduce el problema con el ejemplo proporcionado y compara las cargas útiles codificadas. Se considera terminado cuando los valores BLOB respaldados por NumPy conservan los bytes cero finales, la carga útil coincide con Tablet y la coerción de escalares que no son bytes sigue cubierta por una prueba.

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

Descripción

Search before asking
  • I searched the existing issues for NumpyTablet and BLOB truncation.
Version

Python client from master at 24d22d21ade21e2c9c2e2f04a742e93d7e51df54, Python 3.13.14, NumPy 2.5.5, macOS 15.3.2 arm64.

Minimal reproduction

Run this with the Python client on the import path. It inspects the value bytes used by the insert request and runs without a database.

import numpy as np

from iotdb.utils.IoTDBConstants import TSDataType
from iotdb.utils.NumpyTablet import NumpyTablet
from iotdb.utils.Tablet import Tablet

blob = bytes.fromhex("41 00 00")
columns = ["payload"]
types = [TSDataType.BLOB]
numpy_tablet = NumpyTablet(
    "root.test.d", columns, types, [np.array([blob], dtype=object)], np.array([1])
)
tablet = Tablet("root.test.d", columns, types, [[blob]], [1])
print(numpy_tablet.get_binary_values().hex(" "))
print(tablet.get_binary_values().hex(" "))
Expected result

Both calls should print 00 00 00 03 41 00 00. The first four bytes encode the length, followed by the three original BLOB bytes.

Actual result

NumpyTablet prints 00 00 00 01 41. The regular Tablet prints 00 00 00 03 41 00 00. The NumPy path silently changes the length and contents before the request reaches the server.

Cause and proposed fix

TSDataType.BLOB.np_dtype() returns bytes, so the tablet converts the object column into NumPy's fixed-width byte-string representation. Accessing an element then strips trailing NUL bytes before serialization computes its length.

Use an object dtype for BLOB columns so that each Python bytes value retains its own length until serialization. Callers can use dtype=TSDataType.BLOB.np_dtype() when creating the array. Preserve the existing coercion of non-byte scalars and test the encoded payload against Tablet. An existing fixed-width S array has already lost the distinction between trailing zeros and padding.

Are you willing to submit a PR?
  • Yes.
Lenguaje dominante
Java
Estrellas
6.4k
Forks
1.2k
Merge medio
1 d 12 h
PR fusionados (30 d)
284

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

Todos los issues de apache/iotdb

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.