Skip to content

fix: support non-finite floats in complex results - #574

Merged
cathleeny merged 3 commits into
mainfrom
fix/nested-nonfinite-floats
Nov 19, 2026
Merged

cathleeny merged 3 commits into
mainfrom
fix/nested-nonfinite-floats

Conversation

@cathleeny

@cathleeny cathleeny commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #573.

Valid SQL FLOAT and DOUBLE values containing NaN or infinities currently abort row iteration when nested inside ARRAY, MAP, or STRUCT results. The Go renderers serialize scalar leaves through encoding/json, which rejects non-finite floats.

Render these leaves as the JSON strings "NaN", "Infinity", and "-Infinity" in the shared formatter used by both Thrift and kernel-backed results. Keep SQL NULL as null rather than losing the distinction between special floats and missing values.

Compatibility

  • Finite-number formatting, top-level float values/types, and NULL handling are unchanged.
  • Behavior change: non-finite floating-point MAP keys use the same "NaN", "Infinity", and "-Infinity" spellings as values on both backends. On the kernel backend, keys previously rendered as "+Inf"/"-Inf" now render as "Infinity"/"-Infinity"; "NaN" is unchanged. On Thrift, these keys previously failed row iteration. Recorded in the changelog.
  • Nested special values that previously caused an error now return JSON strings. Applications decoding these leaves must use any or a custom decoder rather than plain float fields; this is documented in README and package docs.
  • No native kernel change, dependency update, or new connection option is needed.

Test Plan

  • New formatter and cross-backend tests failed before the fix.
  • Full default-build CGO_ENABLED=0 go test ./... -count=1 passed with live warehouse credentials removed from the test environment.
  • CGO_ENABLED=1 go test -race ./internal/jsonfmt ./internal/arrowscan ./internal/rows/arrowbased -count=1 passed.
  • CGO_ENABLED=0 go vet ./... passed.
  • make lint passed with zero issues.
  • In-memory Arrow tests cover FLOAT and DOUBLE, arrays, map keys/values (including the same special value as both key and value), structs, nested containers, valid JSON, NULL distinction, and unchanged top-level numeric types. Existing finite-format parity and zero-allocation checks remain enabled.

No live warehouse tests or native-kernel-linked E2E tests were run. Both Go renderers are exercised directly with in-memory Arrow arrays.

This pull request and its description were written by Isaac.

Quote non-finite FLOAT and DOUBLE leaves in the shared JSON formatter instead of aborting row iteration. Preserve finite formatting, SQL NULL, top-level numeric types, and existing kernel MAP-key spellings. Add cross-backend regression coverage and document the encoding.

Signed-off-by: Cathleen Yan <[email protected]>
Co-authored-by: Isaac <[email protected]>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung vuanhphung added the skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test) label Nov 18, 2026
Comment thread internal/jsonfmt/jsonfmt_test.go Resolved
Comment thread internal/jsonfmt/jsonfmt.go Resolved
Render non-finite floating-point MAP keys as "NaN", "Infinity", and "-Infinity", the same strings used for values, instead of keeping the kernel backend's "+Inf"/"-Inf" key spellings. Document the kernel key change as a behavior change. Drop NaN from the scalar benchmark, where encoding/json takes an error path.

Signed-off-by: Cathleen Yan <[email protected]>
Co-authored-by: Isaac <[email protected]>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung vuanhphung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI on cross-connector consistency: the kernel's own complex_types_as_json renderer (used by Python's kernel backend) emits null for nested NaN/±Inf values (json.rs append_float), though it already uses "NaN"/"Infinity"/"-Infinity" for map keys. I think the Go choice is the right one, since it's valid JSON and keeps NULL distinct. I'll file a kernel follow-up to align it. No change needed here.

Comment thread internal/arrowscan/arrowscan.go Resolved
jsonfmt.Append no longer fails on floats, so the fmt "%v" fallback in
writeJSONKey was unreachable for every key scalarForJSON returns. It was
also the only source of the old "+Inf" spelling. Return the error
instead, as the Thrift mapValueContainer does. Fix the stale
marshalScalar comment and list non-finite floats in the package
rendering rules.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Cathleen Yan <[email protected]>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@cathleeny
cathleeny added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit de32629 Nov 19, 2026
16 checks passed
@cathleeny
cathleeny deleted the fix/nested-nonfinite-floats branch November 19, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NaN or Infinity inside ARRAY, MAP or STRUCT fails the whole result

2 participants