Repository navigation
Description
Search before asking
- I searched the existing issues for this problem.
Version
IoTDB server 2.0.12, table model. Tested with the PyPI apache-iotdb==2.0.12 client and with Python client source at 92efb381eee5968236383cdc422766537b20b0af on macOS 15.3.2, Python 3.12.
Describe the bug and provide the minimal reproduce step
A numeric constant in a table query can be returned as a run-length encoded (RLE) TsBlock column. The Python client misreads this column when iterating rows and fails to convert it to a DataFrame.
Create a table in a fresh test database using the table SQL dialect:
CREATE DATABASE rle_example;
USE rle_example;
CREATE TABLE readings (device STRING TAG, v INT32 FIELD);
INSERT INTO readings (time, device, v) VALUES (1, 'a', 11), (2, 'a', 22);With a Python TableSession connected to rle_example, run the same query twice to get a fresh result for each reader:
sql = "SELECT 42 AS label FROM readings"
with session.execute_query_statement(sql) as result:
print([row.get_fields()[0].get_int_value() for row in iter(result.next, None)])
with session.execute_query_statement(sql) as result:
print(result.todf()["label"].tolist())What did you expect to see?
Both calls should return [42, 42], one integer per input row. With SELECT v, 42 AS label FROM readings, the Java CLI returns (11, 42) and (22, 42).
What did you see instead?
| Python client | Row iteration | todf() |
|---|---|---|
92efb381ee |
[0, 0, 0, 42, 0, 0, 0, 42] (eight rows) |
AttributeError: 'bytes' object has no attribute 'dtype' |
PyPI 2.0.12 |
AttributeError: 'bytes' object has no attribute 'dtype' |
Same exception |
With SELECT v, 42 AS label FROM readings, row iteration at 92efb381ee silently returns (11, 0) and (22, 0). The ordinary column limits the result to two rows and masks the row-count error.
Anything else?
The numeric branch of repeat() receives a typed NumPy array, converts it to bytes and concatenates those bytes once per position. For an INT32 value of 42, each copy contributes four bytes (00 00 00 2a). The row reader iterates those bytes individually, and the DataFrame reader tries to access their missing .dtype. An ordinary INT32 column with the same two values decodes correctly. RLE decoder
The proposed fix is to repeat the elements of the numeric array with column.repeat(position_count), preserving the dtype and the existing null bitmap. A regression test should check the values and row count through both public readers.
Are you willing to submit a PR?
- I'm willing to submit a PR!
Prepared with assistance from OpenAI Codex.
Activity
DaZuiZui commentedon Dec 1, 2026
The same decoding bug also affects
FLOAT,INT64, andDOUBLE. With two non-null values in a single RLE column, row iteration at92efb381eereturned 8 rows forFLOATand 16 forINT64andDOUBLE. Callingtodf()on a fresh result raised the sameAttributeErrorfor all three.I also checked two SQL projections against IoTDB 2.0.12 using the two-row
readingstable from the report:CAST('2025-11-23' AS DATE)Invalid date format;todf()raisedTypeError.2025-11-23.CAST(1000 AS TIMESTAMP)The server sent these DATE and TIMESTAMP constants as RLE columns containing INT32 and INT64 values, respectively. Local checks with the patch returned the expected values and row counts for all affected types above. The tested non-null BOOLEAN, TEXT, STRING, and BLOB constants returned the expected two rows both before and after the patch.
DaZuiZui commentedon Dec 1, 2026
Confirmed on 12m2d, 2026y with the latest PyPI release and current upstream master, both against an IoTDB 2.0.12 server. For a table-model query projecting the INT32 literal
43, the server returned a run-length encoded column. The Python decoder expanded the value as raw bytes.apache-iotdb==2.0.12: row iteration andtodf()both raisedAttributeError: 'bytes' object has no attribute 'dtype'.masterat585d88d72ed217846eee813986ca76a772d53a82: row iteration silently returned individual bytes as values, producing incorrect values and extra rows.todf()raised the same exception.Both clients read the ordinary INT32 measurement column in the same table correctly. The expected result for the literal is one integer
43per input row.