eliaperantoni commented on code in PR #15209:
URL: https://github.com/apache/datafusion/pull/15209#discussion_r2001166961
##########
datafusion/sql/src/expr/unary_op.rs:
##########
@@ -45,7 +45,18 @@ 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 span = operand.spans().and_then(|s| s.first());
+ let mut diagnostic = Diagnostic::new_error(
+ format!("+ cannot be used with {data_type}"),
+ span
+ );
+ if span.is_none() {
+ diagnostic.add_note("+ can only be used with
numbers, intervals, and timestamps", None);
+ diagnostic.add_help(format!("perhaps you need to
cast {operand}"), None);
+ }
Review Comment:
Ahh sorry! Hahah. Yeah I meant to say that the note and the help should have
no `Span` attached to them, in my opinion. But they should always be there.
##########
datafusion/sql/src/expr/unary_op.rs:
##########
@@ -45,7 +45,18 @@ 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 span = operand.spans().and_then(|s| s.first());
+ let mut diagnostic = Diagnostic::new_error(
+ format!("+ cannot be used with {data_type}"),
+ span
+ );
+ if span.is_none() {
+ diagnostic.add_note("+ can only be used with
numbers, intervals, and timestamps", None);
+ diagnostic.add_help(format!("perhaps you need to
cast {operand}"), None);
+ }
Review Comment:
Ahh sorry! Hahah. Yeah I meant to say that the note and the help should have
no `Span` attached to them, in my opinion. But they (the note and the help)
should always be there.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]