jonahgao commented on code in PR #11423: URL: https://github.com/apache/datafusion/pull/11423#discussion_r1676031292
########## datafusion/sql/src/relation/join.rs: ########## @@ -107,7 +110,20 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { JoinConstraint::On(sql_expr) => { let join_schema = left.schema().join(right.schema())?; // parse ON expression - let expr = self.sql_to_expr(sql_expr, &join_schema, planner_context)?; + let mut expr = + self.sql_to_expr(sql_expr, &join_schema, planner_context)?; + // ON expression must be a boolean expression + match expr.get_type(&join_schema)? { + DataType::Boolean => {} + DataType::Null => { + expr = Expr::Cast(Cast::new(expr.into(), DataType::Boolean)) + } + other => { + return plan_err!( + "ON expression must be boolean, but got {other:?}" Review Comment: Done. I re-implemented it in `type_coercion` to avoid creating a temporary [joined schema](https://github.com/apache/datafusion/blob/1dfac86a89750193491cf3e04917e37b92c64ffa/datafusion/sql/src/relation/join.rs#L108). Also added a test for DataFrame. -- 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