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

项目:presto-query-formatter    文件:StatementFormatter.java   
@Override
protected Void visitRenameColumn(RenameColumn node, Integer context)
{
    builder.append("ALTER TABLE ")
            .append(node.getTable())
            .append(" RENAME COLUMN ")
            .append(node.getSource())
            .append(" TO ")
            .append(node.getTarget());

    return null;
}
项目:presto    文件:RenameColumnTask.java   
@Override
public CompletableFuture<?> execute(RenameColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
    Session session = stateMachine.getSession();
    QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable());
    Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);

    String source = statement.getSource().toLowerCase(ENGLISH);
    String target = statement.getTarget().toLowerCase(ENGLISH);

    if (!tableHandle.isPresent()) {
        throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
    }
    accessControl.checkCanRenameColumn(session.getRequiredTransactionId(), session.getIdentity(), tableName);

    Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
    if (!columnHandles.containsKey(source)) {
        throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", source);
    }

    if (columnHandles.containsKey(target)) {
        throw new SemanticException(COLUMN_ALREADY_EXISTS, statement, "Column '%s' already exists", target);
    }
    metadata.renameColumn(session, tableHandle.get(), columnHandles.get(source), target);

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

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

    return null;
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitRenameColumn(SqlBaseParser.RenameColumnContext context)
{
    return new RenameColumn(getLocation(context), getQualifiedName(context.tableName), context.from.getText(), context.to.getText());
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testRenameColumn()
        throws Exception
{
    assertStatement("ALTER TABLE foo.t RENAME COLUMN a TO b", new RenameColumn(QualifiedName.of("foo", "t"), "a", "b"));
}