← Back to Pull requests

Return null for json_tuple NULL field names [databricks] #17219

Closed
unknown closed this pull request without merging on Dec 03, 2026 05:54 UTC
View on GitHub
unknown unknown commented on Dec 01, 2026 08:21 UTC
Author

JaCoCo production line coverage: +21 lines (sql-plugin +21; shim 330, single-run fix-line measurement with the json_tuple operator tests)

Fixes #17068.

Description

GPU json_tuple could read an empty-string JSON key when a requested field name was SQL NULL, silently returning a value where Spark returns null. NULL field names now produce null columns; explicitly requested empty names still match empty keys, and valid and repeated names retain their original output positions.

The fix checks the field scalar's cached validity before constructing extraction paths, sends only valid names to the existing matcher, and restores null columns in their requested positions. All-NULL names skip extraction. The tests cover mixed and all-NULL names, output ordering, empty keys, duplicate names and keys, null/malformed JSON, and nested values at 1 KiB and 1 MiB batch sizes; each new case requires GpuGenerateExec.

Local validation used JDK 17, Python 3.10, and an RTX 5880 Ada GPU:

| Runtime | Validation | Result |
|---|---|---|
| Spark 3.3.0 / Scala 2.12 | Distribution build; all json_tuple_test.py tests and every json_tuple case in json_matrix_test.py | Build passed; 56 passed, 1 existing xfailed |
| Spark 4.0.5 / Scala 2.13 | Same build and operator test selection | Build passed; 56 passed, 1 existing xfailed |
| Both runtimes | 14 expanded CPU-first/GPU shell comparisons with executed GPU plans, before the naming-only review update | 14 passed per runtime |
| Spark 3.3.0 | Fresh JaCoCo run of the complete json_tuple operator selection | 56 passed, 1 existing xfailed; 21 added/modified production lines covered |

The retained xfail is nested_escaped_strings.json. ScalaStyle passed with zero errors and warnings. The single-run fix-line measurement includes the only JVM production module changed by this PR and uses classfiles matching the loaded distribution.

Spark 4.0.5 additionally has a CPU whole-stage-codegen issue in the original CASE WHEN reproduction: for a null JSON row, its ordinary-name output can retain the preceding row's value. This was reproduced without RAPIDS, including with the missing-name control. The NULL-name column is fixed here; full original-query parity on Spark 4 was verified with whole-stage codegen disabled, while the materialized-input regressions above pass with normal codegen.

Performance was checked against unmodified main with one million JSON rows, cached input, 1 MiB batches, local[2], AQE disabled, and 20 warmups plus 20 measured samples per workload in separate JVMs. Median latency was 61.459 → 53.432 ms for one valid field and 78.216 → 73.476 ms for eight valid fields. No slowdown was observed in these local workloads; these measurements do not establish a general speedup. The naming-only review update leaves the disassembled runtime instructions unchanged.

AI assistance: The change, regression tests, validation, independent defensive review, and PR description were prepared with Codex assistance.

Checklists

Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 434 lines (+325 / -109) across 5 files Reviewer: firestarman Review duration: 2733m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 434 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #17219"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%