|Title:||LIKELY(), UNLIKELY() and LIKELIHOOD() have affinities|
|Last Modified:||2019-06-11 21:02:25|
|Version Found In:|
mrigger added on 2019-06-11 19:24:14:
Consider the statements below:
SELECT LIKELY(CAST(1 AS INT)) = '1'; -- expected: 0, actual: 1 SELECT UNLIKELY(CAST(1 AS INT)) = '1'; -- expected: 0, actual: 1 SELECT LIKELIHOOD(CAST(1 AS INT), 0.5) = '1'; -- expected: 0, actual: 1
All statements return 1, which is somehow unexpected, since functions are expected to have no affinity; however, it seems that for these functions, the affinity of the function argument is assumed (for LIKELIHOOD, the affinity of the first argument is taken).
This bug report is similar to [d60b3cd7cb], where it was reported that the COLLATE operator takes the affinity of the expression applied to, and resulted in a documentation update.