presto-main/src/main/java/io/prestosql/sql/planner/optimizations/MetadataQueryOptimizer.java/MetadataQueryOptimizer/optimize
class MetadataQueryOptimizer:    @Override
    public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector)
    {
        if (!SystemSessionProperties.isOptimizeMetadataQueries(session)) {
            return plan;
        }
        return SimplePlanRewriter.rewriteWith(new Optimizer(session, metadata, literalEncoder, idAllocator), plan, null);
    }