@Override public Node visitSetOperation(SqlBaseParser.SetOperationContext context) { QueryBody left = (QueryBody) visit(context.left); QueryBody right = (QueryBody) visit(context.right); boolean distinct = context.setQuantifier() == null || context.setQuantifier().DISTINCT() != null; switch (context.operator.getType()) { case SqlBaseLexer.UNION: return new Union(getLocation(context.UNION()), ImmutableList.of(left, right), distinct); case SqlBaseLexer.INTERSECT: return new Intersect(getLocation(context.INTERSECT()), ImmutableList.of(left, right), distinct); case SqlBaseLexer.EXCEPT: return new Except(getLocation(context.EXCEPT()), left, right, distinct); } throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText()); }
@Override protected Void visitExcept(Except node, Integer indent) { processRelation(node.getLeft(), indent); builder.append("EXCEPT "); if (!node.isDistinct()) { builder.append("ALL "); } processRelation(node.getRight(), indent); return null; }
@Override protected RelationType visitExcept(Except node, AnalysisContext context) { throw new SemanticException(NOT_SUPPORTED, node, "EXCEPT not yet implemented"); }