adriangb commented on code in PR #16589: URL: https://github.com/apache/datafusion/pull/16589#discussion_r2265354910
########## datafusion/physical-expr-adapter/src/schema_rewriter.rs: ########## @@ -426,6 +527,77 @@ mod tests { ); } + #[test] + fn test_rewrite_struct_column_incompatible() { + let physical_schema = Schema::new(vec![Field::new( + "data", + DataType::Struct(vec![Field::new("field1", DataType::Binary, true)].into()), + true, + )]); + + let logical_schema = Schema::new(vec![Field::new( + "data", + DataType::Struct(vec![Field::new("field1", DataType::Int32, true)].into()), + true, + )]); + + let factory = DefaultPhysicalExprAdapterFactory; + let adapter = factory.create(Arc::new(logical_schema), Arc::new(physical_schema)); + let column_expr = Arc::new(Column::new("data", 0)); + + let result = adapter.rewrite(column_expr); + assert!(result.is_err()); + let error_msg = result.unwrap_err().to_string(); + assert_contains!(error_msg, "Cannot cast column 'data'"); Review Comment: thanks! 16ed5a045 -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org