gene-bordegaray commented on code in PR #24670:
URL: https://github.com/apache/datafusion/pull/24670#discussion_r3899537773
##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -71,18 +71,23 @@ pub trait ExprSchemable {
-> Result<(DataType, bool)>;
}
-/// Derives the output field for a cast expression from the source field.
+/// Derives the output field for a cast expression from the source field, using
+/// explicit target metadata when supplied.
/// For `TryCast`, `force_nullable` is `true` since a failed cast returns NULL.
fn cast_output_field(
source_field: &FieldRef,
- target_type: &DataType,
+ target: &CastTarget,
force_nullable: bool,
) -> Arc<Field> {
+ let metadata = target
+ .metadata()
+ .cloned()
+ .unwrap_or_else(|| source_field.metadata().clone());
let mut f = source_field
.as_ref()
.clone()
- .with_data_type(target_type.clone())
- .with_metadata(source_field.metadata().clone());
+ .with_data_type(target.data_type().clone())
+ .with_metadata(metadata);
Review Comment:
I will rebase now and the PR should clean up after #23169 merges
--
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]