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

Aberta Para iniciantes
#19,433 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@DaZuiZui já está trabalhando nisso.

Desde 27/11/2026.

  • #19434 de @DaZuiZui — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
85/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
numpy, python
Domínio
databases

Direção de pesquisa

Leia as implementações de NumpyTablet e TSDataType.BLOB.np_dtype() do cliente Python e, em seguida, verifique o caminho de serialização de BLOB junto com Tablet.get_binary_values(). Reproduza o problema com o exemplo fornecido e compare os payloads codificados. O trabalho está concluído quando os valores BLOB baseados em NumPy preservam os bytes zero finais, o payload corresponde ao de Tablet e a coerção de escalares que não são bytes continua coberta por um teste.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
Java
Estrelas
6.4k
Forks
1.2k
Merge médio
1d 12h
PRs com merge (30d)
284

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de apache/iotdb

Todas as issues de apache/iotdb

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.