Skip to content

JVM: keep NaN, inf and -inf in to_json_list and in nested values of the columnar readers - #181

Merged
tae898 merged 3 commits into
mainfrom
fix/jvm-nan-inf
Nov 1, 2026
Merged

tae898 merged 3 commits into
mainfrom
fix/jvm-nan-inf

Conversation

@tae898

@tae898 tae898 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #179

JVM build only (the native readers already return non-finite floats).

  • src/java/com/arcadedb/python/RowBatcher.java: keepNonFinite replaces a non-finite Double/Float (recursing through collections, maps and float/double arrays, copying only when one is found) with the tag the typed rows use; called in appendRow (to_json_list, iter_json_batches) and in ColumnBatcher's json branch.
  • src/arcadedb/results.py: _loads_nonfinite decodes the tag to float('nan') / float('inf') / float('-inf'), and only takes the hook path when a batch contains the tag, so plain batches keep the C decoder. to_json_list returns Python floats, as on native; its docstring says the result is not strict JSON.
  • Tests: tests/test_nonfinite_floats.py (NaN, inf, -inf; top level, in a list, in a map; every reader; rows around a non-finite one unchanged; a string holding the tag character is not turned into a float).

Verification: against the 26.11.1.dev0 wheels of main the JVM wheel fails the to_json_list, iter_json_batches and nested tests (71) and the native wheel passes the whole file (102). Java is compiled and tested by this PR's CI. Updated after #180 merged: main was merged into this branch. For nested list/map values of the columnar readers #180's tagged encoding (TypedRows + _typed_hook) is kept, which keeps non-finite floats the way to_list() does; this PR's keepNonFinite / _loads_nonfinite now cover to_json_list and iter_json_batches (RowBatcher). The tests still check every reader.

🤖 Generated with Claude Code

tae898 and others added 2 commits November 1, 2026 21:15
… the columnar readers

The engine's JSON writers turn non-finite doubles into null, so the JVM build
returned None from to_json_list and, inside a list or a map, from to_columns,
to_dataframe and to_arrow (native keeps them). RowBatcher and ColumnBatcher now
replace each one with the tag {"\u0001": ["f", "NaN"]} and results.py turns it back
into a float, only when the tag character is in the text, so batches without a
non-finite value parse as before. to_json_list returns Python floats, as native.

Java is not compiled here; CI build is the compile check.

Against the main 26.11.1.dev0 wheels the JVM wheel fails the to_json_list, iter_json_batches and nested list/map tests (71 failed) and the native wheel passes the whole file (102 passed). The Java change is compiled and tested by CI.

Closes #179

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#180 writes nested list/map values of the columnar readers with the
TypedRows tagged encoding and decodes them with _typed_hook, the path
to_list() uses, which keeps NaN and the infinities; its version of the
json column (ColumnBatcher and results.py) is kept, and this branch's
keepNonFinite/_loads_nonfinite now cover to_json_list and
iter_json_batches (RowBatcher). tests/test_nonfinite_floats.py still
checks every reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 marked this pull request as ready for review November 1, 2026 13:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit a55fafd into main Nov 1, 2026
36 checks passed
@tae898
tae898 deleted the fix/jvm-nan-inf branch November 1, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JVM: NaN and inf come back as None from to_json_list and inside lists and maps of the columnar readers

1 participant