presto-main/src/main/java/io/prestosql/sql/planner/EffectivePredicateExtractor.java/Visitor/visitValues
class Visitor:        @Override
        public Expression visitValues(ValuesNode node, Void context)
        {
            if (node.getOutputSymbols().isEmpty()) {
                return TRUE_LITERAL;
            }

            // get all types in one shot -- needed for the expression optimizer below
            List<Expression> allExpressions = node.getRows().stream()
                    .flatMap(List::stream)
                    .collect(Collectors.toList());

            Map<NodeRef<Expression>, Type> expressionTypes = typeAnalyzer.getTypes(session, types, allExpressions);

            ImmutableMap.Builder<Symbol, Domain> domains = ImmutableMap.builder();

            for (int column = 0; column < node.getOutputSymbols().size(); column++) {
                Symbol symbol = node.getOutputSymbols().get(column);
                Type type = types.get(symbol);

                ImmutableList.Builder<Object> builder = ImmutableList.builder();
                boolean hasNull = false;
                boolean nonDeterministic = false;
                for (int row = 0; row < node.getRows().size(); row++) {
                    Expression value = node.getRows().get(row).get(column);

                    if (!DeterminismEvaluator.isDeterministic(value, metadata)) {
                        nonDeterministic = true;
                        break;
                    }

                    ExpressionInterpreter interpreter = ExpressionInterpreter.expressionOptimizer(value, metadata, session, expressionTypes);
                    Object evaluated = interpreter.optimize(NoOpSymbolResolver.INSTANCE);

                    if (evaluated instanceof Expression) {
                        return TRUE_LITERAL;
                    }

                    if (evaluated == null) {
                        hasNull = true;
                    }
                    else {
                        builder.add(evaluated);
                    }
                }

                if (nonDeterministic) {
                    // We can't describe a predicate for this column because at least
                    // one cell is non-deterministic, so skip it.
                    continue;
                }

                List<Object> values = builder.build();

                Domain domain = Domain.none(type);

                if (!values.isEmpty()) {
                    domain = domain.union(Domain.multipleValues(type, values));
                }

                if (hasNull) {
                    domain = domain.union(Domain.onlyNull(type));
                }

                domains.put(symbol, domain);
            }

            // simplify to avoid a large expression if there are many rows in ValuesNode
            return domainTranslator.toPredicate(TupleDomain.withColumnDomains(domains.build()).simplify());
        }