dawidwys commented on pull request #12649:
URL: https://github.com/apache/flink/pull/12649#issuecomment-644618279


   Yes, but does it always. We want that behaviour only when accessing the 
field.
   
   Imagine a user function that accepts `ADDRESS(id INT NOT NULL, city STRING)`.
   
   ```
   class UDF extends ScalarFunction {
     public Object eval(Address address) {
        if (address != null) {
            // based on the type I know address.id is NOT NULL here
           int id = address.id;
        }
     }
   }
   ```
   
   but this is not possible in Calcite. There is no way to construct a 
`ADDRESS(id INT NOT NULL, city STRING)`. It will be changed to `ADDRESS(id INT, 
city STRING)`. And based on that there is no way to have the behaviour as 
above. The id is always nullable.
   
   
   
   On the other hand I want the type adjusted if I pass the field only, as this 
might be null without additional checks:
   
   ```
   class UDF2 extends ScalarFunction {
     public Object eval(int id {
     }
   }
   
   // This is illegal. We can not ensure that t.address.id is NOT NULL
   SELECT UDF2(t.address.id) FROM test t;
   ```


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to