Skip to content

fix: Preserve int64 precision when setting nested scalars from JSON - #2556

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
fix/scalar-nested-int64-precision
Aug 4, 2026
Merged

fix: Preserve int64 precision when setting nested scalars from JSON#2556
kodiakhq[bot] merged 1 commit into
mainfrom
fix/scalar-nested-int64-precision

Conversation

@erezrokah

Copy link
Copy Markdown
Member

Follow-up to #2553, which fixed the write-test helpers. The scalar package has the same problem on the read side: Struct.Set and List.Set decode JSON into map[string]any/[]any with the default decoder, so int64/uint64 values beyond float64 precision are rounded before they ever reach a builder.

{"v":-8717895732742165505} came back as {"v":-8717895732742166000}, and [-8717895732742165505] as [-8717895732742165504].

Decode with UseNumber and teach Int, Uint and Float to accept json.Number (delegating to the existing string parse — json.Number is a distinct named type, so the existing case string never matched it).

This is what still blocks the postgresql destination in cloudquery/cloudquery#23163, whose read path goes through scalar.NewScalar/Set.

@kodiakhq
kodiakhq Bot merged commit 65ae9bc into main Aug 4, 2026
10 checks passed
@kodiakhq
kodiakhq Bot deleted the fix/scalar-nested-int64-precision branch August 4, 2026 13:57
kodiakhq Bot pushed a commit that referenced this pull request Aug 4, 2026
🤖 I have created a release *beep* *boop*
---


## [4.96.1](v4.96.0...v4.96.1) (2026-08-04)


### Bug Fixes

* Preserve int64 precision when setting nested scalars from JSON ([#2556](#2556)) ([65ae9bc](65ae9bc))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
erezrokah added a commit to cloudquery/cloudquery that referenced this pull request Aug 4, 2026
…23163)

This PR contains the following updates:

| Package | Change |
|---|---|
| [github.com/apache/arrow-go/v18](https://github.com/apache/arrow-go) |
`v18.6.0` → `v18.7.0` |
|
[github.com/cloudquery/plugin-sdk/v4](https://github.com/cloudquery/plugin-sdk)
| `v4.95.3` → `v4.96.1` |
|
[github.com/cloudquery/filetypes/v4](https://github.com/cloudquery/filetypes)
| `v4.7.1` → `v4.7.3` |

arrow-go v18.7.0 made `array.FromJSON` decode int64/uint64 exactly.
Every other JSON path that rebuilds nested values still went through
float64, so round-trips silently rounded (`-8717895732742165505` became
`-8717895732742165504`) and the mismatch broke the write test suite
across all Go destinations.

Fixed upstream:

- plugin-sdk v4.96.0
(cloudquery/plugin-sdk#2553) — shared write-test
helpers
- plugin-sdk v4.96.1
(cloudquery/plugin-sdk#2556) — the `scalar`
package, which postgresql reads through
- filetypes v4.7.3 (cloudquery/filetypes#757) —
file-based destinations

Fixed here, by decoding nested values with `UseNumber`:

- 16 `AppendValueFromString` call sites across 12 destinations
- `UnmarshalOne` decoders in bigquery, elasticsearch, meilisearch,
mongodb
- postgresql's `stripNullsFromMarshalledJson`
- mongodb's struct/JSON write path, converting `json.Number` to the
integer types the BSON encoder accepts, and its read path, restoring
nested uint64 values stored as int64 bits
- elasticsearch and meilisearch document decodes, with numeric builders
taught to accept `json.Number`
- two float64-rounded literals in the transformer/basic test

azblob fails with `AccountIsDisabled`, which also fails on main and is
unrelated to this PR.

Supersedes #23230, whose plugin-sdk bump is included here — it fails on
its own because v4.96.0 requires arrow v18.7.0.

---------

Co-authored-by: cloudquery-ci[bot] <271027272+cloudquery-ci[bot]@users.noreply.github.com>
Co-authored-by: erezrokah <erezrokah@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants