本文整理匯總了Java中com.facebook.presto.sql.tree.AddColumn類的典型用法代碼示例。如果您正苦於以下問題:Java AddColumn類的具體用法?Java AddColumn怎麽用?Java AddColumn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AddColumn類屬於com.facebook.presto.sql.tree包,在下文中一共展示了AddColumn類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitAddColumn
import com.facebook.presto.sql.tree.AddColumn; //導入依賴的package包/類
@Override
protected Void visitAddColumn(AddColumn node, Integer indent)
{
builder.append("ALTER TABLE ")
.append(node.getName())
.append(" ADD COLUMN ")
.append(node.getColumn().getName())
.append(" ")
.append(node.getColumn().getType());
return null;
}
示例2: execute
import com.facebook.presto.sql.tree.AddColumn; //導入依賴的package包/類
@Override
public CompletableFuture<?> execute(AddColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
accessControl.checkCanAddColumns(session.getRequiredTransactionId(), session.getIdentity(), tableName);
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
TableElement element = statement.getColumn();
Type type = metadata.getType(parseTypeSignature(element.getType()));
if ((type == null) || type.equals(UNKNOWN)) {
throw new SemanticException(TYPE_MISMATCH, element, "Unknown type for column '%s' ", element.getName());
}
if (columnHandles.containsKey(element.getName())) {
throw new SemanticException(COLUMN_ALREADY_EXISTS, statement, "Column '%s' already exists", element.getName());
}
metadata.addColumn(session, tableHandle.get(), new ColumnMetadata(element.getName(), type, false));
return completedFuture(null);
}
示例3: visitAddColumn
import com.facebook.presto.sql.tree.AddColumn; //導入依賴的package包/類
@Override
public Node visitAddColumn(SqlBaseParser.AddColumnContext context)
{
return new AddColumn(getLocation(context), getQualifiedName(context.qualifiedName()), (TableElement) visit(context.tableElement()));
}
示例4: testAddColumn
import com.facebook.presto.sql.tree.AddColumn; //導入依賴的package包/類
@Test
public void testAddColumn()
throws Exception
{
assertStatement("ALTER TABLE foo.t ADD COLUMN c bigint", new AddColumn(QualifiedName.of("foo", "t"), new TableElement("c", "bigint")));
}