eliaperantoni commented on issue #15276: URL: https://github.com/apache/datafusion/issues/15276#issuecomment-2821421644
> [@eliaperantoni](https://github.com/eliaperantoni) I had a follow up question to this regarding the `diagnose` trait function. We want to call the diagnose function during logical planning and pass in `ReturnTypeArgs` and `FnCallSpans` so that the implementor can create a `Diagnostic`. In [#14430](https://github.com/apache/datafusion/issues/14430), the `Diagnostic` is attached to an existing error (via the `with_diagnostic` method) and is then bubbled up. Should the `diagnose` trait function act similarly here? For example, would the `diagnose` function be called [here](https://github.com/apache/datafusion/blob/19a1e58071cd60e74faabab805d97fd269418925/datafusion/expr/src/expr_schema.rs#L435) for a Scalar UDF? And inside the `diagnose` function is where a Scalar UDF implementation would add notes to enrich the error message? Since we're passing in `ReturnTypeArgs` and `FnCallSpans` we can use `ReturnTypeArgs` to determine the erroneous argument and `FnCallSpans` to highlight wher e it is located. Is that right? @jsai28 I'm extremely sorry for the delay 🙏 I've been very busy with other things. But everything you said is absolutely correct. The only think I'd point out is that I think it would be the `diagnose` function itself that creates an error, because otherwise there's none. And then `diagnose` would attach one or more `Diagnostic` to that error. This means that the programmer of a custom UDF has to build and return an error of some kind, even though they might just be interested in creating `Diagnostic`s since that's what ends up being seen by the user. Perhaps we could change the return type of `diagnose` to be `Vec<Diagnostic>`, and if a non empty vec is returned, then we create a standard error (eg. `DataFusionError::Plan("udf is invalid")`) and attach the diagnostics to it? What do you think? -- 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