com.facebook.presto.metadata.Metadata.addColumn()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中com.facebook.presto.metadata.Metadata.addColumn()方法的一些代码示例,展示了Metadata.addColumn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.addColumn()方法的具体详情如下:
包路径:com.facebook.presto.metadata.Metadata
类名称:Metadata
方法名:addColumn

Metadata.addColumn介绍

[英]Add the specified column to the table.
[中]将指定的列添加到表中。

代码示例

代码示例来源:origin: prestodb/presto

metadata.addColumn(session, tableHandle.get(), column);

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@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));

    return completedFuture(null);
  }
}

相关文章