Repository navigation
[Variant] Preserve fixed-point JSON numbers as decimals - #11177
osipovartem wants to merge 9 commits into
Conversation
24a3aca to
a936e5b
Compare
a936e5b to
d6db05a
Compare
|
Hi @osipovartem 👋 thanks for the PR Could you please split this work into separate smaller PRs to make the review process easier? I'd propose adding separate PRs for:
|
|
Thanks, agreed. I split the fallible builder work into #11401, including regression coverage and an independent review. I will separate direct JSON parsing from fixed-point decimal conversion, move benchmarks to their own PR, and check the existing arrow-json decoder APIs before finalizing the parser change. I will update/close this combined PR as the replacements are ready. |
|
Quick correction to my earlier reply: #11401 overlapped with #11106, so I closed it. I extracted the distinct object-field rollback fix into #11403. I won't ask for review of this combined PR as-is; the remaining direct JSON parser, decimal conversion, and benchmarks still need separate PRs. I'll check the existing arrow-json decoder APIs while extracting those pieces, then close #11177 once its replacements are ready. Thanks for the clear split suggestion. |
|
Split complete: the independent upstream PRs are #11106 (fallible builder), #11403 (object rollback), #11409 (direct JSON parser, draft), #11415 (exact decimal conversion, draft), and #11411 (benchmarks). The decimal draft is temporarily stacked on the parser branch; I will rebase it once #11409 lands so its diff contains only decimal changes. No Embucket PRs are needed for review. I am closing this combined draft in favor of those focused Apache PRs. Thanks for the split suggestion. |
…11411) ## Which issue does this PR relate to? Benchmark requested during review of #11177 (related to #11169). It also provides a direct kernel baseline for #11409. ## What changes are included? Extend the existing `parquet-variant-compute` Criterion benchmark for `json_to_variant` with six incremental JSON shapes: Int32, fixed-point decimals, escaped strings, a 1,024-element array, an 8 KiB string, and a 100 KiB duplicate-key object. Existing short-string and nested-structure cases remain unchanged. Each input is prebuilt outside the timed loop into up to 8,000 rows and approximately 1 MiB of JSON. The new cases use the existing `bench_function` naming convention and report bytes per document plus row count in their IDs. No separate serde/builder measurements, library behavior, or public API changes. ## Validation - `cargo +1.95.0 bench -p parquet-variant-compute --bench variant_kernels --offline -- "batch_json_string_to_variant (int32|fixed_point_decimals|escaped_strings|large_array_1024|large_string_8k|duplicate_key_100k)" --quick` (all six new cases ran) - `cargo +1.99.0 clippy -p parquet-variant-compute --bench variant_kernels --offline -- -D warnings` - `cargo +1.95.0 fmt --all -- --check` - Independent read-only review: approved, no blocking findings.
Which issue does this PR close?
What changes are included in this PR?
JsonToVariant::append_jsonnow parses JSON directly intoVariantBuilderExtwhile retaining exact numeric lexemes. The parser:i64;Decimal4,Decimal8, orDecimal16;Double;This deliberately avoids enabling serde_json's workspace-wide
arbitrary_precisionfeature and removes the intermediateserde_json::Valuetree from the string conversion path.The first commit adds a defaulted fallible
VariantBuilderExt::try_append_valuemethod. This lets strict object builders report duplicate fields asArrowErrorinstead of panicking. It also fixes duplicate validation to check before mutating an object's field mapping, so the same builder remains usable after an error.The existing
append_json(&serde_json::Value, ...)API remains available. Its documentation now explains that non-integer numbers useDoublebecause the original fixed-point lexeme is no longer available.Are these changes tested?
Yes. This enables the existing Decimal4/8/16 tests and adds coverage for nested decimals, precision/scale boundaries, malformed JSON, Unicode escapes and surrogate pairs, duplicate fields, recursion limits, error rollback, and the documented difference between the string and
ValueAPIs.Local validation:
cargo +1.95.0 test -p parquet-variant --lib(175 passed)cargo +1.95.0 test -p parquet-variant-json(76 unit tests and 6 doctests passed)cargo +1.95.0 test -p parquet-variant-compute --lib(367 passed)cargo +1.95.0 clippy -p parquet-variant-json --all-targets -- -D warningscargo +1.89.0 check -p parquet-variant-json --all-targetsA Criterion benchmark compares the direct parser with the previous Value-tree path. On this machine the direct path was faster for all covered inputs:
The decimal baseline encodes non-integer numbers as
Double, while the direct path performs the new exact decimal conversion.Are there any user-facing changes?
Yes. Parsing fixed-point JSON text into Variant now preserves exact decimal semantics and precision instead of converting those values to
Double.