paleolimbot commented on code in PR #23169:
URL: https://github.com/apache/datafusion/pull/23169#discussion_r3509305634
##########
datafusion/physical-expr/src/expressions/cast.rs:
##########
@@ -1208,6 +1272,85 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn type_only_cast_strips_extension_metadata() -> Result<()> {
+ // When using type-only cast (new()), extension metadata from source
should NOT propagate
+ let source_meta = HashMap::from([
+ (
+ EXTENSION_TYPE_NAME_KEY.to_string(),
+ "arrow.uuid".to_string(),
+ ),
+ ("custom_key".to_string(), "custom_value".to_string()),
+ ]);
+ let schema = Schema::new(vec![
+ Field::new("a", FixedSizeBinary(16),
false).with_metadata(source_meta),
+ ]);
+
+ let expr = CastExpr::new(col("a", &schema)?, Utf8, None);
+
+ let field = expr.return_field(&schema)?;
+ assert!(
+ field.metadata().get(EXTENSION_TYPE_NAME_KEY).is_none(),
+ "Type-only cast should strip extension type name from source"
+ );
+ assert_eq!(
+ field.metadata().get("custom_key"),
+ Some(&"custom_value".to_string()),
+ "Type-only cast should preserve non-extension metadata"
+ );
+
+ Ok(())
+ }
+
+ #[test]
+ fn field_aware_cast_applies_target_extension_metadata() -> Result<()> {
+ // When using field-aware cast, target's extension metadata should be
applied
+ let source_meta = HashMap::from([
+ (
+ EXTENSION_TYPE_NAME_KEY.to_string(),
+ "source.type".to_string(),
+ ),
+ ("source_key".to_string(), "source_value".to_string()),
Review Comment:
I think I got this one!
--
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]