alamb commented on code in PR #14387: URL: https://github.com/apache/datafusion/pull/14387#discussion_r1937597947
########## datafusion/optimizer/src/analyzer/type_coercion.rs: ########## @@ -190,7 +190,15 @@ impl<'a> TypeCoercionRewriter<'a> { .map(|(lhs, rhs)| { // coerce the arguments as though they were a single binary equality // expression - let (lhs, rhs) = self.coerce_binary_op(lhs, Operator::Eq, rhs)?; + let left_schema = join.left.schema(); Review Comment: The Join output schema is the left schema concatenated with the right schema Normally, since the `lhs` and `rhs` have fully qualified names (`t1.a`, `t2.a`) resolving their types in terms of the output schema is not a problem However, when the relations on both sides have the same relation name but different types (which can happen with DataFrames) it is important to resolve the types in terms of the left/right schema ########## datafusion/core/tests/dataframe/mod.rs: ########## @@ -1121,6 +1121,39 @@ async fn join() -> Result<()> { Ok(()) } +#[tokio::test] +async fn join_coercion_unnnamed() -> Result<()> { + let ctx = SessionContext::new(); + + // Test that join will coerce column types when necessary + // even when the relations don't have unique names Review Comment: > when the columns don't have unique names, is it safe to assume that the unqualified columns in left_cols/right_cols refer to the left/right relations, respectively? Yes, i think so: https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html#method.join Though perhaps we could make that explicit in the docs 🤔 -- 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