Java 类com.facebook.presto.sql.tree.DropView 实例源码

项目:presto    文件:DropViewTask.java   
@Override
public CompletableFuture<?> execute(DropView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
    Session session = stateMachine.getSession();
    QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName());

    Optional<ViewDefinition> view = metadata.getView(session, name);
    if (!view.isPresent()) {
        if (!statement.isExists()) {
            throw new SemanticException(MISSING_TABLE, statement, "View '%s' does not exist", name);
        }
        return completedFuture(null);
    }

    accessControl.checkCanDropView(session.getRequiredTransactionId(), session.getIdentity(), name);

    metadata.dropView(session, name);

    return completedFuture(null);
}
项目:presto-query-formatter    文件:StatementFormatter.java   
@Override
protected Void visitDropView(DropView node, Integer context)
{
    builder.append("DROP VIEW ");
    if (node.isExists()) {
        builder.append("IF EXISTS ");
    }
    builder.append(node.getName());

    return null;
}
项目:sql4es    文件:ESStatement.java   
@Override
public int executeUpdate(String sql) throws SQLException {
    //System.out.println("QUERY: ["+sql+"]");
    sql = sql.replaceAll("\r", " ").replaceAll("\n", " ").trim();
    // custom stuff to support UPDATE statements since Presto does not parse it
    if(sql.toLowerCase().startsWith("update")){
        return updateState.execute(sql);
    }

    com.facebook.presto.sql.tree.Statement statement = parser.createStatement(sql);
    if(statement instanceof Query) throw new SQLException("A regular query cannot be executed as an Update");
    if(statement instanceof Insert){
        //if(connection.getSchema() == null) throw new SQLException("No active index set for this driver. Pleas specify an active index or alias by executing 'USE <index/alias>' first");
        return updateState.execute(sql, (Insert)statement, connection.getSchema());
    }else if(statement instanceof Delete){
        if(connection.getSchema() == null) throw new SQLException("No active index set for this driver. Pleas specify an active index or alias by executing 'USE <index/alias>' first");
        return updateState.execute(sql, (Delete)statement, connection.getSchema());
    }else if(statement instanceof CreateTable){
        return updateState.execute(sql, (CreateTable)statement, connection.getSchema());
    }else if(statement instanceof CreateTableAsSelect){
        return updateState.execute(sql, (CreateTableAsSelect)statement, connection.getSchema());
    }else if(statement instanceof CreateView){
        return updateState.execute(sql, (CreateView)statement, connection.getSchema());
    }else if(statement instanceof Use){
        connection.setSchema( ((Use)statement).getSchema());
        //connection.getTypeMap(); // updates the type mappings found in properties
        return 0;
    }else if(statement instanceof DropTable){
        return updateState.execute(sql, (DropTable)statement);
    }else if(statement instanceof DropView){
        return updateState.execute(sql, (DropView)statement);
    }throw new SQLFeatureNotSupportedException("Unable to parse provided update sql");
}
项目:sql4es    文件:ESUpdateState.java   
/**
 * Executes the {@link BulkRequest} being hold by this state.
 * @return an integer indicator for each executed request: Statement.SUCCESS_NO_INFO for success, 
 * else Statement.EXECUTE_FAILED)
 */
public int[] executeBulk(){
    int[] result = new int[bulkList.size()];
    SqlParser parser = new SqlParser();
    for(int i=0; i<bulkList.size(); i++) try{
        String sql = bulkList.get(i);
        com.facebook.presto.sql.tree.Statement st = parser.createStatement(sql);
        if(st instanceof DropTable){
            this.execute(sql, (DropTable)st);
        }else if(st instanceof DropView){
            this.execute(sql, (DropView)st);
        }else if(st instanceof CreateTable){
            this.execute(sql, (CreateTable)st, this.statement.getConnection().getSchema());
        }else if(st instanceof CreateTableAsSelect){
            this.execute(sql, (CreateTableAsSelect)st, this.statement.getConnection().getSchema());
        }else if(st instanceof CreateView){
            this.execute(sql, (CreateView)st, this.statement.getConnection().getSchema());
        }else if(st instanceof Delete){
            this.execute(sql, (Delete)st, this.statement.getConnection().getSchema());
        }else  if(st instanceof Insert){
            this.execute(sql, (Insert)st, this.statement.getConnection().getSchema());
        }
        result[i]= Statement.SUCCESS_NO_INFO;
    }catch (Exception e){
        result[i] = Statement.EXECUTE_FAILED;
    }
    this.clearBulk();
    return result;
}
项目:presto    文件:SqlFormatter.java   
@Override
protected Void visitDropView(DropView node, Integer context)
{
    builder.append("DROP VIEW ");
    if (node.isExists()) {
        builder.append("IF EXISTS ");
    }
    builder.append(node.getName());

    return null;
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testDropView()
        throws Exception
{
    assertStatement("DROP VIEW a", new DropView(QualifiedName.of("a"), false));
    assertStatement("DROP VIEW a.b", new DropView(QualifiedName.of("a", "b"), false));
    assertStatement("DROP VIEW a.b.c", new DropView(QualifiedName.of("a", "b", "c"), false));

    assertStatement("DROP VIEW IF EXISTS a", new DropView(QualifiedName.of("a"), true));
    assertStatement("DROP VIEW IF EXISTS a.b", new DropView(QualifiedName.of("a", "b"), true));
    assertStatement("DROP VIEW IF EXISTS a.b.c", new DropView(QualifiedName.of("a", "b", "c"), true));
}
项目:EchoQuery    文件:SqlFormatter.java   
@Override
protected Void visitDropView(DropView node, Integer context)
{
    builder.append("DROP VIEW ");
    if (node.isExists()) {
        builder.append("IF EXISTS ");
    }
    builder.append(node.getName());

    return null;
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitDropView(SqlBaseParser.DropViewContext context)
{
    return new DropView(getLocation(context), getQualifiedName(context.qualifiedName()), context.EXISTS() != null);
}
项目:airpal    文件:InputReferenceExtractor.java   
@Override
protected CatalogSchemaContext visitDropView(DropView node, CatalogSchemaContext context)
{
    references.add(qualifiedNameToTable(node.getName(), context));
    return context;
}