← Back to Pull requests

fix: return a scalar field from a scalar struct in GetStructField #7381

Open
unknown opened this pull request with 229 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 01, 2026 02:08 UTC
Author

Which issue does this PR close?

Closes #7380.

Rationale for this change

When the input of GetStructField is a scalar struct, the native kernel returns the field as a one-row array. Beside a column, that array does not match the batch's row count and the query fails. The scalar arm has done this since the expression was added, but a scalar struct rarely reached it until #5452 made CreateNamedStruct return a scalar when every field value is a scalar. A DataFusion scalar UDF would have its one-row result turned back into a scalar by ScalarFunctionExpr, but GetStructField is a PhysicalExpr and gets no such conversion. Split out of #5526.

What changes are included in this PR?

GetStructField returns a scalar when its input is a scalar struct. The field still goes through child_with_parent_nulls, so the field of a null struct is null. A list field is wrapped as a list scalar directly rather than through ScalarValue::try_from_array, which rebuilds the element field without its metadata (such as a Variant element's extension type), so the scalar's type would no longer match the declared type.

How are these changes tested?

  • A query at the end of struct/get_struct_field.sql reads a field of a cast named_struct over a scalar subquery, once with a value and once with NULL, over four rows in one batch. It fails on main with Array length 1 does not match expected length 4.

  • Rust unit tests evaluate GetStructField over a scalar struct and check that it returns a scalar, for a present struct, a null struct, and a null struct whose child still holds a value, and for a typed and a Null-typed field. Another checks that a list field whose element field carries metadata keeps the declared type. Each test fails without its part of the fix.
  • Assisted-by: Claude Code (claude-opus-5-5)

    Diff: 229 lines (+171 / -58) across 2 files Reviewer: sunchao Review duration: 43238m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 229 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.325
    Real PR Conversation Timeline
    1 comments
    "Review active on #7381"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 37.0% (MEDIUM) · Higher = larger blast radius
    37.0%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 21.1% · Safe to merge
    21.1%