presto-main/src/main/java/io/prestosql/sql/rewrite/ShowStatsRewrite.java/Visitor/visitShowStats
class Visitor:        @Override
        protected Node visitShowStats(ShowStats node, Void context)
        {
            checkState(queryExplainer.isPresent(), "Query explainer must be provided for SHOW STATS SELECT");

            if (node.getRelation() instanceof TableSubquery) {
                Query query = ((TableSubquery) node.getRelation()).getQuery();
                QuerySpecification specification = (QuerySpecification) query.getQueryBody();
                Plan plan = queryExplainer.get().getLogicalPlan(session, query(specification), parameters, warningCollector);
                validateShowStatsSubquery(node, query, specification, plan);
                Table table = (Table) specification.getFrom().get();
                Constraint constraint = getConstraint(plan);
                return rewriteShowStats(node, table, constraint);
            }
            if (node.getRelation() instanceof Table) {
                Table table = (Table) node.getRelation();
                return rewriteShowStats(node, table, Constraint.alwaysTrue());
            }
            throw new IllegalArgumentException("Expected either TableSubquery or Table as relation");
        }