Hello all, we're using `RexProgram.expandLocalRef()` and `RexProgram.expandList()` to have a simple RexNode which we later evaluate. However, if the program contains a non-deterministic function call in the common subexpressions, such call is inlined and can be called a different number of times as a result, leading to an incorrect result.
This problem spreads to anywhere these methods are used, and it's used quite a many times in Calcite, and we've also hit it in our custom rule. It seems to me that this function is flawed by design and should be removed as it leads to correctness problems with non-deterministic functions. Or should be redesigned, because perhaps some uses are valid, for example the one to determine selectivity in `RelMdSelectivity`. What do others think about this? Viliam -- This message contains confidential information and is intended only for the individuals named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version. -Hazelcast
