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

Aperta Adatta ai principianti
#19,433 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@DaZuiZui ci sta già lavorando.

Dal 27/11/2026.

  • #19434 di @DaZuiZui — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
numpy, python
Ambito
databases

Direzione di ricerca

Leggi le implementazioni di NumpyTablet e TSDataType.BLOB.np_dtype() del client Python, poi controlla il percorso di serializzazione dei BLOB insieme a Tablet.get_binary_values(). Riproduci il problema con l’esempio fornito e confronta i payload codificati. Il lavoro è completato quando i valori BLOB basati su NumPy mantengono i byte zero finali, il payload corrisponde a quello di Tablet e la coercizione degli scalari non di tipo byte è ancora coperta da un test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Java
Stelle
6.4k
Fork
1.2k
Merge medio
1g 12h
PR unite (30g)
284

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iotdb

Tutte le issue di apache/iotdb

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.