myandpr opened a new issue, #20988:
URL: https://github.com/apache/datafusion/issues/20988
### Describe the bug
An invalid unary negation expression can escape analyzer/type coercion
validation when wrapped by `IS NULL`.
For example, `SELECT * FROM (SELECT 1) WHERE ((-'a') IS NULL)` is accepted
during planning and optimization, even though `-'a'` is not a valid negation
expression.
### To Reproduce
```rust
#[tokio::test]
async fn wrapped_negation_is_accepted() {
let ctx = SessionContext::new();
let plan = ctx
.sql("SELECT * FROM (SELECT 1) WHERE ((-'a') IS NULL)")
.await
.unwrap()
.into_optimized_plan();
assert!(plan.is_ok());
}
```
I also verified that the same query executes successfully and returns Ok([])
before the fix.
### Expected behavior
Invalid wrapped negation expressions such as (-'a') IS NULL should be
rejected during analyzer/type coercion, rather than being accepted.
### Additional context
This appears to be a gap in expression validation for `Expr::Negative`.
--
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]