fix: return a scalar field from a scalar struct in GetStructField #7381
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
sunchao
Which issue does this PR close?
Closes #7380.
Rationale for this change
When the input of
GetStructFieldis 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 madeCreateNamedStructreturn a scalar when every field value is a scalar. A DataFusion scalar UDF would have its one-row result turned back into a scalar byScalarFunctionExpr, butGetStructFieldis aPhysicalExprand gets no such conversion. Split out of #5526.What changes are included in this PR?
GetStructFieldreturns a scalar when its input is a scalar struct. The field still goes throughchild_with_parent_nulls, so the field of a null struct is null. A list field is wrapped as a list scalar directly rather than throughScalarValue::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?
struct/get_struct_field.sqlreads a field of a castnamed_structover a scalar subquery, once with a value and once with NULL, over four rows in one batch. It fails onmainwithArray length 1 does not match expected length 4.GetStructFieldover 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)