xuyangzhong opened a new pull request, #23779: URL: https://github.com/apache/flink/pull/23779
## What is the purpose of the change Currently RAND and RAND_INTEGER are always return type "NOT NULL" as built in functions in `FlinkSqlOperatorTable`. But when codegen, the result type is always nullable in `RandCallGen`. Actually, the result type of RAND and RAND_INTEGER should depend on the types of arguments. For example, If the argument is nullable, the return type should be nullable. This bug causes the error with pattern "IF(1 = 1, RAND(0), 0)", because the following logic: 1. the result type of RAND is always "not null" when validation in `FlinkSqlOperatorTable`, and the third param is 0 that is always "not null", so the return type of operator IF is always "not null". 2. when codegen operator RAND, the return type of RAND(0) is always "nullable" 3. when codegen operator IF, the CAST rule cannot cast from "nullable" (the second arg RAND) to "not null"(the result type), so the exception throws. ## Brief change log - *correct the return type to be nullable when one of its args is nullable during validation* - *correct the final return type to be nullable when the original result type is nullable during codegen* - *add tests* ## Verifying this change Some tests are added to verify this pr. ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? no -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org