-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Search before asking
- I searched in the issues and found nothing similar.
Version
Environment
| Component | Version/Info |
|---|---|
| OS | Ubuntu 24.04 LTS (Noble Numbat) |
| IoTDB Server | 1.2.2 (Build: 5d0bfb0) |
| Python Client | apache-iotdb==2.0.6 |
| Python | Python 3.12.8 |
| Query Method | execute_query_statement() + todf() |
Describe the bug and provide the minimal reproduce step
Description
When executing a multi-field SELECT query using the Python client (apache-iotdb==2.0.6) against IoTDB server 1.2.2, the returned column values are swapped/misaligned with their corresponding column names when the query contains backtick-quoted measurement paths.
Single-field queries return correct results, and the same query executed via CLI returns consistent/correct results. This suggests a column mapping issue in the Python client's todf() result conversion when handling multiple backtick-quoted paths.
Steps to Reproduce
-
Insert test data for two measurements with backtick-quoted device names:
-- Example data setup (adjust as needed) INSERT INTO root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`(time, D1_Energy0) VALUES (1774368000000, 4.028076); INSERT INTO root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`(time, D1_Energy0) VALUES (1774368000000, 17.917969);
-
Execute the following query via Python client:
QUERY_MULTI_FIELD = """ SELECT `Asm-M1-9c9e6e185958`.D1_Energy0, `Asm-M1-58cf79150b64`.D1_Energy0 FROM root.D8646300001.** WHERE time >= 1774285200000 and time <= 1774368000000 ORDER BY time ASC; """.strip() rs = iotdb.execute_query_statement(QUERY_MULTI_FIELD) df_todf = rs.todf() print("[todf] columns:", list(df_todf.columns)) print("head(1):\n", df_todf.head(1).to_string()) print("first row dict:", df_todf.iloc[0].to_dict())
-
Execute the same query via IoTDB CLI:
SELECT `Asm-M1-9c9e6e185958`.D1_Energy0, `Asm-M1-58cf79150b64`.D1_Energy0 FROM root.D8646300001.** WHERE time >= 1774285200000 and time <= 1774368000000 ORDER BY time ASC;
✅ CLI output:
+-----------------------------+--------------------------------------------------------+--------------------------------------------------------+
| Time|root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0|root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0|
+-----------------------------+--------------------------------------------------------+--------------------------------------------------------+
|2026-03-25T00:00:00.000+08:00| 4.028076| 17.917969|
+-----------------------------+--------------------------------------------------------+--------------------------------------------------------+
What did you expect to see?
Expected Behavior
Python client todf() should return column values aligned with their column names, matching CLI output:
[todf] columns: [
'Time',
'root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0',
'root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0'
]
head(1):
Time root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0 root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0
0 1774368000000 4.028076 17.917969
first row dict: {
'Time': 1774368000000.0,
'root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0': 4.028076171875,
'root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0': 17.91796875
}
What did you see instead?
Actual Behavior
Column values are swapped in Python client output:
[todf] columns: [
'Time',
'root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0',
'root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0'
]
head(1):
Time root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0 root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0
0 1774368000000 17.917969 4.028076 # ← Values swapped!
first row dict: {
'Time': 1774368000000.0,
'root.D8646300001.Asm_M1.`Asm-M1-9c9e6e185958`.D1_Energy0': 17.91796875, # ← Wrong value
'root.D8646300001.Asm_M1.`Asm-M1-58cf79150b64`.D1_Energy0': 4.028076171875 # ← Wrong value
}
Anything else?
✅ Single-field queries in Python also return correct values
QUERY_SINGLE_FIELD1 = """
SELECT Asm-M1-9c9e6e185958.D1_Energy0
FROM root.D8646300001.**
WHERE time >= 1774285200000 and time <= 1774368000000
ORDER BY time ASC;
""".strip()
QUERY_SINGLE_FIELD2 = """
SELECT Asm-M1-58cf79150b64.D1_Energy0
FROM root.D8646300001.**
WHERE time >= 1774285200000 and time <= 1774368000000
ORDER BY time ASC;
""".strip()
Are you willing to submit a PR?
- I'm willing to submit a PR!