presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/UnwrapCastInComparison.java/UnwrapCastInComparison/hasInjectiveImplicitCoercion
class UnwrapCastInComparison:        private boolean hasInjectiveImplicitCoercion(Type source, Type target)
        {
            if ((source.equals(BIGINT) && target.equals(DOUBLE)) ||
                    (source.equals(BIGINT) && target.equals(REAL)) ||
                    (source.equals(INTEGER) && target.equals(REAL))) {
                // Not every BIGINT fits in DOUBLE/REAL due to 64 bit vs 53-bit/23-bit mantissa. Similarly,
                // not every INTEGER fits in a REAL (32-bit vs 23-bit mantissa)
                return false;
            }

            if (source instanceof DecimalType) {
                int precision = ((DecimalType) source).getPrecision();

                if (precision > 15 && target.equals(DOUBLE)) {
                    // decimal(p,s) with p > 15 doesn't fit in a double without loss
                    return false;
                }

                if (precision > 7 && target.equals(REAL)) {
                    // decimal(p,s) with p > 7 doesn't fit in a double without loss
                    return false;
                }
            }

            // Well-behaved implicit casts are injective
            return new TypeCoercion(metadata::getType).canCoerce(source, target);
        }