ScalarUDFImpl::preimage allows defining "preimage" (range of input values) for function outputs, which can be used to rewrite binary comparison expressions.
The rewrite rules for equality (=) or inequality (!=) seem intuitive. But f(x) <= c would also be rewritten to x < u where u is the (exclusive) upper bound. (Here is the code.) I'm not sure if this holds in general. Does this assume that the function must be monotonically non-decreasing?
I was trying to see if the documentation mentions monotonicity for scalar UDFs but I couldn't find it. Let me know if I misunderstood anything!
ScalarUDFImpl::preimageallows defining "preimage" (range of input values) for function outputs, which can be used to rewrite binary comparison expressions.The rewrite rules for equality (
=) or inequality (!=) seem intuitive. Butf(x) <= cwould also be rewritten tox < uwhereuis the (exclusive) upper bound. (Here is the code.) I'm not sure if this holds in general. Does this assume that the function must be monotonically non-decreasing?I was trying to see if the documentation mentions monotonicity for scalar UDFs but I couldn't find it. Let me know if I misunderstood anything!