eliaperantoni commented on code in PR #15209: URL: https://github.com/apache/datafusion/pull/15209#discussion_r1995063039
########## datafusion/sql/src/expr/unary_op.rs: ########## @@ -45,7 +45,13 @@ impl<S: ContextProvider> SqlToRel<'_, S> { { Ok(operand) } else { - plan_err!("Unary operator '+' only supports numeric, interval and timestamp types") + plan_err!("Unary operator '+' only supports numeric, interval and timestamp types").map_err(|e| { + let spans = operand.spans(); + let span = if let Some(s) = spans.as_ref() { s.first() } else { None }; Review Comment: ```suggestion let spans = operand.spans().map(|s| s.first()); ``` ########## datafusion/sql/src/expr/unary_op.rs: ########## @@ -45,7 +45,13 @@ impl<S: ContextProvider> SqlToRel<'_, S> { { Ok(operand) } else { - plan_err!("Unary operator '+' only supports numeric, interval and timestamp types") + plan_err!("Unary operator '+' only supports numeric, interval and timestamp types").map_err(|e| { + let spans = operand.spans(); + let span = if let Some(s) = spans.as_ref() { s.first() } else { None }; + let diagnostic = + Diagnostic::new_error("Unary operator '+' only supports numeric, interval and timestamp types".to_string(), span); Review Comment: Not a big deal but I think this message is a bit long for a `Diagnostic` and it addresses the problem in a very broad way, saying "+ only works with X, Y, and Z" instead of simply "+ cannot be used with W". Is it possible to make the `Diagnostic` look like this: - message = "+ cannot be used with {type-name}" - note (without span) = "+ can only be used with numbers, intervals, and timestamps" - help (without span) = "perhaps you need to cast {expression}" -- 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