@Override public Node visitGroupBy(SqlBaseParser.GroupByContext context) { return new GroupBy(getLocation(context), isDistinct(context.setQuantifier()), visit(context.groupingElement(), GroupingElement.class)); }
@Override public Node visitGroupBy(SqlBaseParser.GroupByContext context) { return new GroupBy(getLocation(context), isDistinct(context.setQuantifier()), visit(context.groupingElement(), GroupingElement.class)); }
@Override public Node visitQuerySpecification(SqlBaseParser.QuerySpecificationContext context) { Optional<Relation> from = Optional.empty(); List<SelectItem> selectItems = visit(context.selectItem(), SelectItem.class); List<Relation> relations = visit(context.relation(), Relation.class); if (!relations.isEmpty()) { // synthesize implicit join nodes Iterator<Relation> iterator = relations.iterator(); Relation relation = iterator.next(); while (iterator.hasNext()) { relation = new Join(getLocation(context), Join.Type.IMPLICIT, relation, iterator.next(), Optional.empty()); } from = Optional.of(relation); } return new QuerySpecification( getLocation(context), new Select(getLocation(context.SELECT()), isDistinct(context.setQuantifier()), selectItems), from, visitIfPresent(context.where, Expression.class), visitIfPresent(context.groupBy(), GroupBy.class), visitIfPresent(context.having, Expression.class), Optional.empty(), Optional.empty()); }
@Override public Node visitQuerySpecification(SqlBaseParser.QuerySpecificationContext context) { Optional<Relation> from = Optional.empty(); List<SelectItem> selectItems = visit(context.selectItem(), SelectItem.class); List<Relation> relations = visit(context.relation(), Relation.class); if (!relations.isEmpty()) { // synthesize implicit join nodes Iterator<Relation> iterator = relations.iterator(); Relation relation = iterator.next(); while (iterator.hasNext()) { relation = new Join(getLocation(context), Join.Type.IMPLICIT, relation, iterator.next(), Optional.empty()); } from = Optional.of(relation); } return new QuerySpecification( getLocation(context), new Select(getLocation(context.SELECT()), isDistinct(context.setQuantifier()), selectItems), from, visitIfPresent(context.where, Expression.class), visitIfPresent(context.groupBy(), GroupBy.class), visitIfPresent(context.having, Expression.class), Optional.empty(), Optional.empty()); }
boolean distinct = isDistinct(context.setQuantifier());
boolean distinct = isDistinct(context.setQuantifier());