comphead commented on code in PR #24680:
URL: https://github.com/apache/datafusion/pull/24680#discussion_r3866880206
##########
datafusion/physical-expr-adapter/src/schema_rewriter.rs:
##########
@@ -309,26 +317,60 @@ fn resolve_field_path<'a>(
}
}
+/// Retain only the selected field path in a cast target, preserving its Struct
+/// ancestors' metadata and nullability. This excludes unselected sibling
+/// conversions while keeping the all-null Struct shortcut for decimal casts.
+fn retain_field_path(field: &FieldRef, path: &[&str]) -> Option<FieldRef> {
+ let Some((name, rest)) = path.split_first() else {
+ return Some(Arc::clone(field));
+ };
+ let DataType::Struct(fields) = field.data_type() else {
+ return None;
+ };
Review Comment:
```suggestion
let DataType::Struct(fields) = field.data_type() else {
return None;
};
let Some((name, rest)) = path.split_first() else {
return Some(Arc::clone(field));
};
```
maybe we can swap early returns?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]