alamb commented on code in PR #4258: URL: https://github.com/apache/arrow-datafusion/pull/4258#discussion_r1026837425
########## datafusion/sql/src/planner.rs: ########## @@ -3165,6 +3171,64 @@ fn wrap_projection_for_join_if_necessary( Ok((plan, need_project)) } +/// Ensure any column reference of the expression is determined. Review Comment: Another term for this concept is `unambiguous` ########## datafusion/sql/src/planner.rs: ########## @@ -3165,6 +3171,64 @@ fn wrap_projection_for_join_if_necessary( Ok((plan, need_project)) } +/// Ensure any column reference of the expression is determined. +/// Assume we have two schema: +/// schema1: a, b ,c +/// schema2: a, d, e +/// +/// `schema1.a + schema2.a` is determined. +/// `a + d` is not determined, because `a` may come from schema1 or schema2. +fn ensure_any_column_reference_is_determined( + expr: &Expr, + schemas: &[DFSchemaRef], +) -> Result<()> { + if schemas.len() == 1 { + return Ok(()); + } + + // extract columns both in one more schemas. + let mut column_count_map: HashMap<String, usize> = HashMap::new(); Review Comment: You might be able to avoid a clone into a string here. Maybe a follow on PR ```suggestion let mut column_count_map: HashMap<&str, usize> = HashMap::new(); ``` -- 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...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org