eliaperantoni commented on code in PR #14521: URL: https://github.com/apache/datafusion/pull/14521#discussion_r1946069829
########## datafusion/common/src/column.rs: ########## @@ -299,6 +301,23 @@ impl Column { .flat_map(|s| s.columns()) .collect(), }) + .map_err(|e| match &e { + DataFusionError::SchemaError( + SchemaError::FieldNotFound { + field, + valid_fields, + }, + _, + ) => { + let mut diagnostic = Diagnostic::new_error( + format!("column '{}' is ambiguous", &field.name()), + field.spans().first(), + ); + add_possible_column_notes(&mut diagnostic, field, valid_fields); + e.with_diagnostic(diagnostic) + } + _ => e, + }) Review Comment: Are you sure that this is a case of ambiguous column? It looks like this is hit if none of the `schemas` have any matching fields, also indicated by the fact that the error this is mapping is a static `SchemaError::FieldNotFound` (which I guess would be enriched with a `Diagnostic` further up in the call stack, there's a test for that). I think perhaps you meant to call `add_possible_column_notes(&mut diagnostic, field, valid_fields)` between lines 278-290, where a "column '{}' is ambiguous" `Diagnostic` is already created. ########## datafusion/common/src/error.rs: ########## @@ -709,6 +723,27 @@ pub fn unqualified_field_not_found(name: &str, schema: &DFSchema) -> DataFusionE }) } +pub fn add_possible_column_notes( Review Comment: Perhaps the name of this function should in some way convey the fact that it has to do with `Diagnosic`, otherwise it's a bit generic. `add_possible_columns_to_diag` maybe. -- 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