@Override protected Void visitShowStats(ShowStats node, Integer context) { builder.append("SHOW STATS FOR "); process(node.getRelation(), 0); builder.append(""); return null; }
@Override public Node visitShowStatsForQuery(SqlBaseParser.ShowStatsForQueryContext context) { QuerySpecification specification = (QuerySpecification) visitQuerySpecification(context.querySpecification()); Query query = new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()); return new ShowStats(Optional.of(getLocation(context)), new TableSubquery(query)); }
@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, new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()), parameters, warningCollector); validateShowStatsSubquery(node, query, specification, plan); Table table = (Table) specification.getFrom().get(); Constraint<ColumnHandle> constraint = getConstraint(plan); return rewriteShowStats(node, table, constraint); } else if (node.getRelation() instanceof Table) { Table table = (Table) node.getRelation(); return rewriteShowStats(node, table, Constraint.alwaysTrue()); } else { throw new IllegalArgumentException("Expected either TableSubquery or Table as relation"); } }
@Override public Node visitShowStats(SqlBaseParser.ShowStatsContext context) { return new ShowStats(Optional.of(getLocation(context)), new Table(getQualifiedName(context.qualifiedName()))); }
@Override protected Void visitShowStats(ShowStats node, Integer context) { builder.append("SHOW STATS FOR "); process(node.getRelation(), 0); builder.append(""); return null; }
@Test public void testShowStats() { final String[] tableNames = {"t", "s.t", "c.s.t"}; for (String fullName : tableNames) { QualifiedName qualifiedName = QualifiedName.of(Arrays.asList(fullName.split("\\."))); assertStatement(format("SHOW STATS FOR %s", qualifiedName), new ShowStats(new Table(qualifiedName))); } }
@Override protected Void visitShowStats(ShowStats node, Integer context) { builder.append("SHOW STATS FOR "); process(node.getRelation(), 0); builder.append(""); return null; }
private ShowStats createShowStats(QualifiedName name, List<SelectItem> selects, Optional<Expression> where) { return new ShowStats( new TableSubquery(simpleQuery(new Select(false, selects), new Table(name), where, Optional.empty()))); }
@Override public Node visitShowStatsForQuery(SqlBaseParser.ShowStatsForQueryContext context) { QuerySpecification specification = (QuerySpecification) visitQuerySpecification(context.querySpecification()); Query query = new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()); return new ShowStats(Optional.of(getLocation(context)), new TableSubquery(query)); }
@Override public Node visitShowStats(SqlBaseParser.ShowStatsContext context) { return new ShowStats(Optional.of(getLocation(context)), new Table(getQualifiedName(context.qualifiedName()))); }
@Test public void testShowStats() { final String[] tableNames = {"t", "s.t", "c.s.t"}; for (String fullName : tableNames) { QualifiedName qualifiedName = QualifiedName.of(Arrays.asList(fullName.split("\\."))); assertStatement(format("SHOW STATS FOR %s", qualifiedName), new ShowStats(new Table(qualifiedName))); } }
private ShowStats createShowStats(QualifiedName name, List<SelectItem> selects, Optional<Expression> where) { return new ShowStats( new TableSubquery(simpleQuery(new Select(false, selects), new Table(name), where, Optional.empty()))); }