@Override protected Void visitDropTable(final DropTable node, final Integer context) { builder.append("DROP TABLE "); if (node.getIfExists()) { builder.append("IF EXISTS "); } builder.append(node.getName()); return null; }
protected Node visitDropTable(final DropTable node, final Object context) { return new DropTable(node.getLocation(), node.getTableName(), node.getIfExists(), node.isDeleteTopic()); }
private static CommandId getDropTableCommandId(final DropTable dropTableQuery) { return new CommandId( CommandId.Type.TABLE, dropTableQuery.getName().getSuffix(), CommandId.Action.DROP ); }
@Override public Node visitDropTable(final SqlBaseParser.DropTableContext context) { return new DropTable( Optional.of(getLocation(context)), getQualifiedName(context.qualifiedName()), context.EXISTS() != null, context.DELETE() != null ); }
@Test public void shouldParseDropTableIfExists() { final String simpleQuery = "DROP TABLE IF EXISTS TABLE1;"; final Statement statement = KSQL_PARSER.buildAst(simpleQuery, metaStore).get(0).getStatement(); assertThat(statement, instanceOf(DropTable.class)); final DropTable dropTable = (DropTable) statement; assertThat(dropTable.getName().toString().toUpperCase(), equalTo("TABLE1")); assertThat(dropTable.getIfExists(), is(true)); }
@Test public void shouldParseDropTable() { final String simpleQuery = "DROP TABLE TABLE1;"; final Statement statement = KSQL_PARSER.buildAst(simpleQuery, metaStore).get(0).getStatement(); assertThat(statement, instanceOf(DropTable.class)); final DropTable dropTable = (DropTable) statement; assertThat(dropTable.getName().toString().toUpperCase(), equalTo("TABLE1")); assertThat(dropTable.getIfExists(), is(false)); }