CritasWang opened a new pull request, #15:
URL: https://github.com/apache/iotdb-client-nodejs/pull/15
Fixes #14
### Problem
The Node.js client serializes `DATE` (TSDataType 9) values as *days since
Unix epoch* and deserializes them the same way. IoTDB's actual DATE wire format
is an **INT32 encoded as `year*10000 + month*100 + day`** (e.g. `2026-07-13` →
`20260713`), as implemented by:
- Java: `DateUtils.parseDateExpressionToInt` / `parseIntToDate`
(`iotdb-core`)
- C# client: same yyyyMMdd INT32 encoding
- Rust client: verified via a live adjudication test against IoTDB 2.0.6 — a
row inserted via SQL literal `'2026-07-13'` reads back as raw i32 `20260713` on
the wire
Consequences of the old behavior: dates written via `insertTablet` from
Node.js were stored as small integers (~20655 for 2026), which other clients
decode as year-0002 nonsense; dates written by any other client (~2026xxxx)
decoded in Node.js as dates around year 57000.
### Fix
- New shared utils `parseDateToInt` / `parseIntToDate` in
`src/utils/DataTypes.ts` (exported from the package index). Calendar components
are taken in UTC, matching Java `LocalDate` semantics (no timezone math).
- Applied in all four DATE paths: `Session.serializeColumn` (tablet write),
`FastSerializer.serializeDateColumn` (fast write path),
`Session.deserializeColumn` (TSQueryDataSet read),
`ColumnDecoder`/`parseTsBlock` (TsBlock read).
- Additional fix discovered during verification: TsBlock headers report DATE
columns with wire type INT32 (1); the DATE type is only in the response
metadata. `parseTsBlock` now converts such columns to `Date` objects using
`dataTypeList`, so query results return `Date` instead of raw integers.
- Null handling unchanged (null → 0 on write, bitmap-null → `null` on read).
### Verification
- Unit tests: yyyyMMdd round-trip, exact serialization byte vector
(`20260713` → `01 35 27 69` big-endian), TsBlock column decode. 124/124 pass.
- Live IoTDB 2.0.6: a `Date('2026-07-13')` written via binary tablet and a
`'2026-07-13'` SQL literal now read back identical
(`2026-07-13T00:00:00.000Z`); previously the tablet row was corrupted.
- `npm run build` and existing e2e data-type suites pass against a live
server.
⚠️ Behavior change: code that relied on the old (incorrect) days-since-epoch
numbers for DATE columns will see different values. This is a wire-format
correctness fix required for interoperability with the Java, C#, Python, and
Rust clients.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]