Acfboy opened a new issue, #20356:
URL: https://github.com/apache/datafusion/issues/20356

   ### Is your feature request related to a problem or challenge?
   
   Now, types of expressions in `WHERE/HAVING/ORDER BY/ON` closure would not be 
checked at logical planning but checked in type_coercion while generating 
physical plan.
   
   For insurance:
   ```rust
   #[tokio::test]
   async fn test_unary_negation_on_string_error() -> Result<()> {
        let test_sqls = vec![
                // "SELECT (1 + 'a') FROM (SELECT 1);",
                "SELECT * FROM (SELECT 1) WHERE (1 + 'a');",
                // "SELECT count(*) FROM (SELECT 1) GROUP BY (1 + 'a');",
                "SELECT column1 FROM (VALUES (1)) AS t(column1) GROUP BY 
column1 HAVING (1 + 'a');",
                "SELECT * FROM (SELECT 1) ORDER BY (1 + 'a');",
                "SELECT * FROM (SELECT 1) AS t1 JOIN (SELECT 1) AS t2 ON (1 + 
'a');",
        ];
        let mut cnt = 0;
        for sql in test_sqls {
                let ctx = SessionContext::new();
                if ctx.sql(sql).await.is_err() {
                        cnt += 1;
                }
        }
        assert_eq!(4, cnt);
        Ok(())
   }
   ```
   The test above will fail.
   
   I think we should report error as early as possible, the statements above 
should reject invalid expressions in logical planning phase just as `SELECT (1 
+ 'a') FROM (SELECT 1);`
   
   ### Describe the solution you'd like
   
   I plan to follow the error-handling pattern used for `SELECT 1 + 'a'`; by 
invoking `Expr::to_field`. I would welcome any alternative approaches or 
suggestions on the implementation details.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
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]

Reply via email to