-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Emit warning with attached Diagnostic
when doing = NULL
#14434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this is a good first issue as the need is clear and the tests in https://github.com/apache/datafusion/blob/85fbde2661bdb462fc498dc18f055c44f229604c/datafusion/sql/tests/cases/diagnostic.rs are well structured for extension. |
take |
Hey @ugoa how is it going with this ticket :) Can I help with anything? |
Yeah I am working on it this weekend |
Hi @ugoa, I noticed that this ticket was assigned to you a couple weeks ago. May I ask if any progress has been made? If you are willing to cooperate, I would be happy to submit a PR to help resolve this issue. Please let me know if this works for you. Appreciate your efforts! |
Hi @eliaperantoni, Thank you raising this issue. As I explore potential implementations, I’d appreciate your insights on a few key points: 1. Warning Scope for
2. Non-Fatal Warning Plumbing 3. Span Highlighting Strategy
I have come up with some possible approaches:
What would be the best approach in your opinion? Thank you for your guidance! |
Thank you @changsun20 for the detailed analysis 🙏 1. Warning Scope for = NULL PatternsI would say that, if's not too complicated, we should go for the semantic approach. i.e. only raise a warning when 2. Non-Fatal Warning PlumbingThis is a complicated one! 😃 You hit the nail on the head: the complicated part is bubbling up a warning without interrupting everything. I haven't thought too much about how to solve it. Perhaps one way would be to make a fn parse_query(sql: &str) -> DatafusionResult<LogicalPlan> {
let mut warnings = WarningAccumulator::new();
// WarningAccumulator::extend(&mut self) takes a DatafusionResult<R> and
// returns Result<R>, while storing any warnings in itself.
let ctes = warnings.extend(parse_ctes(sql))?;
let mut logical_plan = warnings.extend(parse_select(sql, ctes))?;
warnings.extend(parse_where(&mut logical_plan, sql))?;
// WarningAccumulator::into returns Vec<DatafusionWarning>
DatafusionResult::ok_with_warnings(logical_plan, warnings.into())
} But I believe that's a bit invasive because it requires replacing Alternatively, to start with we could add a field to 3. Span Highlighting Strategy
This means changing the If that doesn't work, I would suggest perhaps going the easy route of highlighting the expression and saying "this expression is being compared with |
Hi @eliaperantoni, Thank you for the detailed guidance! Here's my understanding of the next steps:
Thanks again for your guidance. I'll start working on an implementation based on these suggestions. Appreciate your patience as I navigate the codebase! |
Quick update: I was a bit busy with schoolwork last week, but I’ll try to fix this ticket this week. Thanks for your patience! |
No worries at all! <3 |
Is your feature request related to a problem or challenge?
For a query like:
DataFusion does not emit any error. Of course this a valid query, but it's very likely that the user intended to do
password IS NULL
instead.We want to provide a rich message that references and highlights locations in the original SQL query, and contextualises and helps the user understand the pitfall. In the end, it would be possible to display a warning in a fashion akin to what was enabled by #13664 for some (fatal) errors:
See #14429 for more information.
Describe the solution you'd like
Attach a well crafted
Diagnostic
to theDataFusionError
, building on top of the foundations laid in #13664. See #14429 for more information.There would probably need to be some plumbing required to make DataFusion collect warnings without halting the overall execution. In this scenario, we want to use
Diagnostic::new_warning
.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: