Skip to content

JVM wheel: Result.to_json() writes a DATE and a DATETIME of a projection row differently from its own record rows and from the native wheel #453

Open

Description

@tae898

On the JVM wheel the same DATE or DATETIME has two JSON forms in Result.to_json(), depending on whether the row is a record or a projection. On the native wheel it has one. The probe behind #446 gave, for a row with a DATE and a DATETIME:

Row arcadedb-jvm arcadedb (native)
projection {"n":0,"day":1767312000000,"ts":"2026-01-02 03:04:05"} {"n":0,"day":20455,"ts":1767323045678}
record "day":20455,"ts":1767323045678 "day":20455,"ts":1767323045678

So the JVM wheel writes a projection DATE as epoch milliseconds (the record row has days) and a projection DATETIME as a text without the milliseconds (the record row has epoch milliseconds, ...678). The native wheel gives the same value for both kinds of row. Anything that reads to_json() and then switches between SELECT * and SELECT a, b on the JVM wheel gets a different unit or type for the same column.

What I would do: make the projection row of the JVM wheel the same as the record row, which is also what the native wheel does. I have not read where the JVM wheel writes the projection (the glue or the engine's JSON writer), so I do not know yet which side the fix goes in. The golden test then pins the projection case too (today it pins only the record row, where the wheels agree).

Refs #314 (item 3 of the status comment of 2026-11-22).

Activity

  1. added this to the 26.12.1 milestone on Nov 22, 2026
  2. self-assigned this
    on Nov 22, 2026
  3. added
    bug
    python
    jvm
    on Nov 22, 2026
  4. added
    native
    on Nov 22, 2026
  5. tae898 commented on Nov 22, 2026

    @tae898
    CollaboratorAuthor

    I traced where the two forms come from. It is the engine, not this repository: Result.to_json() of the JVM wheel is str(self._java_result.toJSON()) (src/arcadedb/results.py), and no Java file in src/java/ writes the JSON of a result. Read at the tag 26.11.1 of ArcadeData/arcadedb (the same methods on main at d6b48767cb84):

    • A record row (SELECT FROM ...) goes through getElement().get().toJSON() and JsonSerializer.map2json. A DATE column becomes epoch days (20455), other temporals epoch milliseconds (1767323045678).
    • A projection row (SELECT day, ts ...) is a non-element ResultInternal. Its toJSON() calls Result.valueToJSON per property. A LocalDateTime is formatted with the schema's date-time format ("2026-01-02 03:04:05", the milliseconds are gone), and a LocalDate has no branch, so JSONObject writes the epoch milliseconds of its UTC midnight (1767312000000).

    Upstream issues ArcadeData/arcadedb#9037 and #9810 deal with this writer, and tests/test_temporal_writers_agree.py says the bridge keeps no encoder of its own, so I do not want to patch the text in Python for the DATE and DATETIME of the top level only (it would leave a DATETIME inside a list or map, and DATETIME_MICROS and DATETIME_NANOS columns, different anyway). The fix belongs in Result.valueToJSON, where both wheels would get it after an engine release. The native wheel writes the record form for both kinds of row with its own codec, so it is the JVM wheel that follows the engine here.

    Decision: this is not a regression and it needs an engine change, so I moved it from 26.12.1 to 27.1.1. The next step is an upstream issue with a Java repro on the engine API (two rows, the probe table of #446) that proposes the record form for a projection, for the maintainers to decide. Until then the to_json() docstring says the two forms exist, and the golden test pins only the record row.

  6. modified the milestones: 26.12.1, 27.1.1 on Nov 22, 2026
  7. tae898 commented on Nov 23, 2026

    @tae898
    CollaboratorAuthor

    I filed the question upstream with a Java repro on the engine API (JDK 21 and 25, engine 26.11.1): ArcadeData/arcadedb#13129. It asks whether a projection row should write a DATE and a DATETIME the way the record row does, and offers a patch for Result.valueToJSON if the answer is yes. This issue stays in 27.1.1 until they answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugjvmnativepython

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions