fix: preserve Arrow field metadata in element_at, GetStructField, and CreateNamedStruct #7774
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 406 lines diff across 5 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
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7774"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7769
Rationale for this change
ListExtract,SparkMapExtract,GetStructField, andCreateNamedStructwere dropping Arrow field metadata (including Arrow extension types such asVariantType) because they relied on DataFusion's defaultPhysicalExpr::return_field/ScalarUDFImpl::return_field_from_argsor rebuiltField::new(...)fromdata_type+nullable. Additionally,PhysicalPlanner::create_scalar_function_exprreconstructedarg_fieldsand the outputFieldfromDataTypes, stripping metadata for scalar UDFs likemap_extract.What changes are included in this PR?
ListExtract(native/spark-expr/src/array_funcs/list_extract.rs): Updatedchild_fieldto usereturn_fieldand overrodePhysicalExpr::return_fieldto preserve the inner element field's metadata.SparkMapExtract(native/spark-expr/src/map_funcs/map_extract.rs): OverrodeScalarUDFImpl::return_field_from_argsto preserve the map value field's metadata.GetStructField(native/spark-expr/src/struct_funcs/get_struct_field.rs): Updatedchild_fieldto usereturn_fieldand overrodePhysicalExpr::return_fieldto preserve the child struct field's metadata.CreateNamedStruct(native/spark-expr/src/struct_funcs/create_named_struct.rs): Updatedfields()to useexpr.return_field(schema)?with.with_name(name)instead ofField::new(...).PhysicalPlanner::create_scalar_function_expr(native/core/src/execution/planner.rs): Propagated inputreturn_fields intoarg_fieldsand preserved theFieldRefreturned byreturn_field_from_argsonScalarFunctionExpr.(Note: Under ANSI mode with nullable array/map operands,
CometElementAt.needsNullGuardwrapsListExtract/map_extractinCaseWhenExpr, which still uses the defaultreturn_field. LeavingCaseWhenExprout of this PR to keep scope focused; happy to follow up if desired.)How are these changes tested?
Added unit tests covering all 4 expressions and end-to-end planner integration (
map_extract_preserves_field_metadata_through_planner).<details>
<summary>Before fix (4 reproduction tests failing with empty metadata <code>{}</code>)</summary>
</details>
<details>
<summary>After fix (all unit tests, planner tests, fmt, and clippy passing)</summary>
cargo test -p datafusion-comet-spark-expr --lib preserves_field_metadata: 4 passed; 0 failedcargo test -p datafusion-comet --lib preserves_field_metadata: 3 passed; 0 failedcargo test -p datafusion-comet --lib execution::planner::tests: 81 passed; 0 failedcargo fmt --check: passedcargo clippy -p datafusion-comet-spark-expr -p datafusion-comet --tests: passed</details>