presto-main/src/main/java/io/prestosql/sql/relational/SqlToRowExpressionTranslator.java/SqlToRowExpressionTranslator/translate
class SqlToRowExpressionTranslator:    public static RowExpression translate(
            Expression expression,
            Map<NodeRef<Expression>, Type> types,
            Map<Symbol, Integer> layout,
            Metadata metadata,
            Session session,
            boolean optimize)
    {
        Visitor visitor = new Visitor(
                metadata,
                types,
                layout,
                session.getTimeZoneKey(),
                SystemSessionProperties.isLegacyTimestamp(session));
        RowExpression result = visitor.process(expression, null);

        requireNonNull(result, "translated expression is null");

        if (optimize) {
            ExpressionOptimizer optimizer = new ExpressionOptimizer(metadata, session);
            return optimizer.optimize(result);
        }

        return result;
    }