alamb commented on a change in pull request #8460:
URL: https://github.com/apache/arrow/pull/8460#discussion_r504969480



##########
File path: rust/datafusion/src/physical_plan/expressions.rs
##########
@@ -1985,9 +1982,10 @@ mod tests {
 
     #[test]
     fn invalid_cast() -> Result<()> {
-        let schema = Schema::new(vec![Field::new("a", DataType::Utf8, false)]);
-        let result = cast(col("a"), &schema, DataType::Int32);
-        result.expect_err("Invalid CAST from Utf8 to Int32");
+        // Ensure a useful error happens at plan time if invalid casts are used

Review comment:
       > If/when we get to that point, we'll have to think about what behaviour 
we want DataFusion to use.
   
   I think DataFusion now makes the distinction between "casting" (aka if the 
user specifically requests to cast from one type to another) which can be lossy 
and "coercion" (aka when casts need to be added explicitly so that expressions 
can be evaluated (e.g. plus). 
   
   Coercion is designed not be lossy, but casting can be. 
   
   The downside is that Datafusion has to have another set of rules of what 
type coercions are allowed (e.g. I need to add 
https://github.com/apache/arrow/pull/8463 to properly support DictionaryArray 
in DataFusion). 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to