Repository navigation
JVM: to_json_list() returns a float for every DECIMAL, also of scale 0, as the native wheel does (#452) - #456
Merged
Merged
Conversation
…0, as the native wheel does (#452) The JSON of the JVM wheel printed a DECIMAL of scale 0 without a fraction ("3"), which Python parsed as an int, and a 20-digit integral value as an int of 20 digits, where the native wheel returns float(Decimal). RowBatcher.keepNonFinite now turns a BigDecimal into the nearest double, at the top level and inside a list or a map, so one column has one Python type on both wheels. A value too large for a double takes the existing tag and arrives as inf, like float(Decimal) on the native wheel. tests/test_cross_wheel_golden.py asserts a float on both wheels for Decimal("3"), Decimal("-7") and the 20-digit values (1.2345678901234567e+19), and checks iter_json_batches and the exact Decimal of to_list(). The to_json_list() docstring and the Results list of the databases-and-queries page say that every DECIMAL is a float and that more than about 17 digits are rounded. The Java change was not compiled on the machine that wrote it; CI builds the bridge jar. Closes #452. Refs #314.
tae898
added a commit
that referenced
this pull request
Nov 23, 2026
…(#N) after the pull request number (#467) A dry run for 26.12.1 listed 'fix(#412): the native bytes cache ...' and 'JVM: to_json_list() ... (#452) (#456)'. The prefix carries an issue number and a process word that a reader of a release does not need, and the bare number next to the number of the pull request is an issue reference of the same kind as the (refs #N) notes that are already left out. A title that is nothing but such text is kept as it is.
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The JVM wheel now returns a
floatfor everyDECIMALinto_json_list()anditer_json_batches(), as the docstring says and as the native wheel does, so one column has one Python type on both wheels. Before, the JSON of the JVM wheel printed aDECIMALof scale 0 without a fraction (3), which Python parsed as anint, and a 20-digit integral value as anintof 20 digits where the native wheel gives the nearest double.The conversion is in the Java bridge, in
RowBatcher.keepNonFinite, the function that already widens aFloatand tags NaN and the infinities: aBigDecimalbecomes the nearestdouble(BigDecimal.doubleValue()), at the top level and inside a list or a map, the wayjson_nativedoes on the native wheel. A value too large for a double takes the existing tag and arrives asinf, asfloat(Decimal)gives on the native wheel. The fix cannot be in the Python parse: the JSON text of aDECIMAL3and of anINTEGER3is the same, so only the Java side still knows the type.tests/test_cross_wheel_golden.py: the case that accepted anintor afloatforDecimal("3")andDecimal("-7")now asserts afloat(3.0,-7.0) on both wheels, keepsDecimal("2.00"), and adds the 20-digit valuesDecimal("12345678901234567890")and its negative as floats (1.2345678901234567e+19). It also checks thatiter_json_batches(batch_size=1)returns the same rows and thatto_list()still returns every digit as aDecimal. The bullet of the module docstring that listed this difference as open is removed.What each wheel returns, from the probe table of #446 (wheels built from
62195709b7, x86-64 Linux, Python 3.12). Thearcadedb-jvmafter column is what this change is meant to give, not a measurement: CI asserts it.arcadedb-jvmbeforearcadedb-jvmafterarcadedb(native, unchanged)Decimal("3")int 3float 3.0float 3.0Decimal("-7")int -7float -7.0float -7.0Decimal("2.00")float 2.0float 2.0float 2.0Decimal("12345678901234567890")int 12345678901234567890float 1.2345678901234567e+19float 1.2345678901234567e+19A DECIMAL that has a fraction already lost exactness as a float on both wheels; this makes the integral case do the same.
to_list(),to_columns()andto_arrow()keep the exactDecimaland are not changed.The Java change was not compiled and the tests were not run on my machine; the CI build of the bridge jar and the test run are the check.
Related issues
Closes #452. Refs #314 (item 1 of the status comment of 2026-11-22).
Docs
The docstring of
to_json_list()and the Results list ofdocs/modules/ROOT/pages/how-to/databases-and-queries.adocnow say that everyDECIMALis afloatwhatever its scale and that more than about 17 digits are rounded. I searchedtests/,docs/,README.md,examples/and the docstrings for a place that says or asserts that aDECIMALarrives as aninton the JVM wheel: onlytests/test_cross_wheel_golden.pydid, and it is fixed here. There is no changelog file in the repository: the release notes are built from the titles and labels of merged pull requests, so the title of this one is the line (labelbug).Checklist
intis from the probe of Tests: four more cross-wheel golden cases: to_json text, to_arrow float lists, vector distances, integral DECIMAL (refs #314) #446)tests/test_cross_wheel_golden.py24 passed, 0 failed)uvx pre-commit run --files <changed files>passes (second run clean), withcompile()andpyflakeson the two Python files