presto-main/src/main/java/io/prestosql/sql/planner/NullabilityAnalyzer.java/NullabilityAnalyzer/visitCast
class NullabilityAnalyzer:        @Override
        protected Void visitCast(Cast node, AtomicBoolean result)
        {
            // Certain casts (e.g., cast(JSON 'null' AS ...)) can return null, but we know
            // that any "type-only" coercion cannot produce null on non-null input, so
            // take advantage of that fact to produce a more precise result.
            //
            // TODO: need a generic way to determine whether a CAST can produce null on non-null input.
            // This should be part of the metadata associated with the CAST. (N.B. the rules in
            // ISO/IEC 9075-2:2016, section 7.16.21 seems to imply that CAST cannot return NULL
            // except for the CAST(NULL AS x) case -- we should fix this at some point)
            //
            // Also, try_cast (i.e., safe cast) can return null
            result.set(node.isSafe() || !node.isTypeOnly());
            return null;
        }