@Override public Node visitExplainFormat(SqlBaseParser.ExplainFormatContext context) { switch (context.value.getType()) { case SqlBaseLexer.GRAPHVIZ: return new ExplainFormat(getLocation(context), ExplainFormat.Type.GRAPHVIZ); case SqlBaseLexer.TEXT: return new ExplainFormat(getLocation(context), ExplainFormat.Type.TEXT); case SqlBaseLexer.JSON: return new ExplainFormat(getLocation(context), ExplainFormat.Type.JSON); } throw new IllegalArgumentException("Unsupported EXPLAIN format: " + context.value.getText()); }
@Test public void testExplain() { assertStatement("EXPLAIN SELECT * FROM t", new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of())); assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL)))); assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of( new ExplainType(ExplainType.Type.LOGICAL), new ExplainFormat(ExplainFormat.Type.TEXT)))); }
@Override public Node visitExplainFormat(SqlBaseParser.ExplainFormatContext context) { switch (context.value.getType()) { case SqlBaseLexer.GRAPHVIZ: return new ExplainFormat(getLocation(context), ExplainFormat.Type.GRAPHVIZ); case SqlBaseLexer.TEXT: return new ExplainFormat(getLocation(context), ExplainFormat.Type.TEXT); case SqlBaseLexer.JSON: return new ExplainFormat(getLocation(context), ExplainFormat.Type.JSON); } throw new IllegalArgumentException("Unsupported EXPLAIN format: " + context.value.getText()); }
@Override public Node visitExplainFormat(SqlBaseParser.ExplainFormatContext context) { switch (context.value.getType()) { case SqlBaseLexer.GRAPHVIZ: return new ExplainFormat(getLocation(context), ExplainFormat.Type.GRAPHVIZ); case SqlBaseLexer.TEXT: return new ExplainFormat(getLocation(context), ExplainFormat.Type.TEXT); } throw new IllegalArgumentException("Unsupported EXPLAIN format: " + context.value.getText()); }
@Test public void testExplain() throws Exception { assertStatement("EXPLAIN SELECT * FROM t", new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, ImmutableList.of())); assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL)))); assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, ImmutableList.of( new ExplainType(ExplainType.Type.LOGICAL), new ExplainFormat(ExplainFormat.Type.TEXT)))); }
@Test public void testExplain() { assertStatement("EXPLAIN SELECT * FROM t", new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of())); assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL)))); assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t", new Explain( simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), false, false, ImmutableList.of( new ExplainType(ExplainType.Type.LOGICAL), new ExplainFormat(ExplainFormat.Type.TEXT)))); }