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

项目:presto    文件:RenameTableTask.java   
@Override
public CompletableFuture<?> execute(RenameTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
    Session session = stateMachine.getSession();
    QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getSource());
    Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
    if (!tableHandle.isPresent()) {
        throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
    }

    QualifiedObjectName target = createQualifiedObjectName(session, statement, statement.getTarget());
    if (!metadata.getCatalogNames().containsKey(target.getCatalogName())) {
        throw new SemanticException(MISSING_CATALOG, statement, "Target catalog '%s' does not exist", target.getCatalogName());
    }
    if (metadata.getTableHandle(session, target).isPresent()) {
        throw new SemanticException(TABLE_ALREADY_EXISTS, statement, "Target table '%s' already exists", target);
    }
    if (!tableName.getCatalogName().equals(target.getCatalogName())) {
        throw new SemanticException(NOT_SUPPORTED, statement, "Table rename across catalogs is not supported");
    }
    accessControl.checkCanRenameTable(session.getRequiredTransactionId(), session.getIdentity(), tableName, target);

    metadata.renameTable(session, tableHandle.get(), target);

    return completedFuture(null);
}
项目:presto-query-formatter    文件:StatementFormatter.java   
@Override
protected Void visitRenameTable(RenameTable node, Integer context)
{
    builder.append("ALTER TABLE ")
            .append(node.getSource())
            .append(" RENAME TO ")
            .append(node.getTarget());

    return null;
}
项目:presto    文件:SqlFormatter.java   
@Override
protected Void visitRenameTable(RenameTable node, Integer context)
{
    builder.append("ALTER TABLE ")
            .append(node.getSource())
            .append(" RENAME TO ")
            .append(node.getTarget());

    return null;
}
项目:EchoQuery    文件:SqlFormatter.java   
@Override
protected Void visitRenameTable(RenameTable node, Integer context)
{
    builder.append("ALTER TABLE ")
            .append(node.getSource())
            .append(" RENAME TO ")
            .append(node.getTarget());

    return null;
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitRenameTable(SqlBaseParser.RenameTableContext context)
{
    return new RenameTable(getLocation(context), getQualifiedName(context.from), getQualifiedName(context.to));
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testRenameTable()
        throws Exception
{
    assertStatement("ALTER TABLE a RENAME TO b", new RenameTable(QualifiedName.of("a"), QualifiedName.of("b")));
}
项目:airpal    文件:InputReferenceExtractor.java   
@Override
protected CatalogSchemaContext visitRenameTable(RenameTable node, CatalogSchemaContext context)
{
    references.add(qualifiedNameToTable(node.getSource(), context));
    return context;
}