paleolimbot commented on code in PR #27383:
URL: https://github.com/apache/datafusion/pull/27383#discussion_r4602587548


##########
datafusion/common/src/nested_struct.rs:
##########
@@ -1225,6 +1451,87 @@ mod tests {
         Arc::new(struct_field(name, fields))
     }
 
+    fn bool8_field(name: &str) -> Field {
+        Field::new(name, DataType::Int8, true).with_metadata(HashMap::from([(
+            "ARROW:extension:name".to_string(),
+            "arrow.bool8".to_string(),
+        )]))
+    }
+
+    #[derive(Debug)]
+    struct Bool8ToStringCast;
+
+    impl CastExtension for Bool8ToStringCast {
+        fn can_cast_fields(
+            &self,
+            source_field: &Field,
+            target_field: &Field,
+        ) -> Result<bool> {
+            Ok(source_field
+                .metadata()
+                .get("ARROW:extension:name")
+                .map(String::as_str)
+                == Some("arrow.bool8")
+                && source_field.data_type() == &DataType::Int8

Review Comment:
   I think this would be the role of the CastExtension (it could return true 
for the "can cast types" but error for a cast it thought was inappropriate).



-- 
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]

Reply via email to