本文整理了Java中com.facebook.presto.metadata.Metadata.getColumnHandles()
方法的一些代码示例,展示了Metadata.getColumnHandles()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getColumnHandles()
方法的具体详情如下:
包路径:com.facebook.presto.metadata.Metadata
类名称:Metadata
方法名:getColumnHandles
[英]Gets all of the columns on the specified table, or an empty map if the columns can not be enumerated.
[中]获取指定表中的所有列,如果无法枚举这些列,则获取空映射。
代码示例来源:origin: prestodb/presto
private Optional<ColumnHandle> getColumnHandle(TableHandle tableHandle, Session session, Metadata metadata)
{
return metadata.getColumnHandles(session, tableHandle).entrySet()
.stream()
.filter(entry -> columnName.equals(entry.getKey()))
.map(Map.Entry::getValue)
.findFirst();
}
代码示例来源:origin: prestodb/presto
protected final List<Type> getColumnTypes(String tableName, String... columnNames)
{
checkState(session.getCatalog().isPresent(), "catalog not set");
checkState(session.getSchema().isPresent(), "schema not set");
// look up the table
Metadata metadata = localQueryRunner.getMetadata();
QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName);
TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName)
.orElseThrow(() -> new IllegalArgumentException(format("Table %s does not exist", qualifiedTableName)));
Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
return Arrays.stream(columnNames)
.map(allColumnHandles::get)
.map(columnHandle -> metadata.getColumnMetadata(session, tableHandle, columnHandle).getType())
.collect(toImmutableList());
}
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
ImmutableList.Builder<ColumnHandle> columnHandlesBuilder = ImmutableList.builder();
for (String columnName : columnNames) {
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
for (Map.Entry<String, Domain> expectedColumnConstraint : expectedDomains.get().entrySet()) {
if (!columnHandles.containsKey(expectedColumnConstraint.getKey())) {
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, targetTableHandle.get());
analysis.setInsert(new Analysis.Insert(
targetTableHandle.get(),
代码示例来源:origin: prestodb/presto
ColumnHandle columnHandle = metadata.getColumnHandles(session, tableHandle).get(column);
if (columnHandle == null) {
throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", column);
代码示例来源:origin: prestodb/presto
TableHandle tableHandle = metadata.getTableHandle(session, name)
.orElseThrow(() -> new PrestoException(INVALID_SPATIAL_PARTITIONING, format("Table not found: %s", name)));
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
List<ColumnHandle> visibleColumnHandles = columnHandles.values().stream()
.filter(handle -> !metadata.getColumnMetadata(session, tableHandle, handle).isHidden())
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
ColumnHandle columnHandle = columnHandles.get(source);
if (columnHandle == null) {
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
代码示例来源:origin: prestodb/presto
private Node rewriteShowStats(ShowStats node, Table table, Constraint<ColumnHandle> constraint)
{
TableHandle tableHandle = getTableHandle(node, table.getName());
TableStatistics tableStatistics = metadata.getTableStatistics(session, tableHandle, constraint);
List<String> statsColumnNames = buildColumnsNames();
List<SelectItem> selectItems = buildSelectItems(statsColumnNames);
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableHandle);
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle);
List<Expression> resultRows = buildStatisticsRows(tableMetadata, columnHandles, tableStatistics);
return simpleQuery(selectAll(selectItems),
aliased(new Values(resultRows),
"table_stats_for_" + table.getName(),
statsColumnNames));
}
代码示例来源:origin: prestodb/presto
Map<String, ColumnHandle> columns = metadata.getColumnHandles(session, insert.getTarget());
Assignments.Builder assignments = Assignments.builder();
for (ColumnMetadata column : tableMetadata.getColumns()) {
代码示例来源:origin: com.facebook.presto/presto-benchmark
protected final List<Type> getColumnTypes(String tableName, String... columnNames)
{
checkState(session.getCatalog().isPresent(), "catalog not set");
checkState(session.getSchema().isPresent(), "schema not set");
// look up the table
Metadata metadata = localQueryRunner.getMetadata();
QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName);
TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName)
.orElseThrow(() -> new IllegalArgumentException(format("Table %s does not exist", qualifiedTableName)));
Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
return Arrays.stream(columnNames)
.map(allColumnHandles::get)
.map(columnHandle -> metadata.getColumnMetadata(session, tableHandle, columnHandle).getType())
.collect(toImmutableList());
}
代码示例来源:origin: com.facebook.presto/presto-benchmark
Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
ImmutableList.Builder<ColumnHandle> columnHandlesBuilder = ImmutableList.builder();
for (String columnName : columnNames) {
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@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);
}
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, targetTableHandle.get());
analysis.setInsert(new Analysis.Insert(
targetTableHandle.get(),
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
Map<ColumnHandle, String> columnHandles = ImmutableBiMap.copyOf(metadata.getColumnHandles(session, tableHandle.get())).inverse();
Map<ColumnHandle, MethodHandle> methodHandles = new HashMap<>();
for (ColumnHandle columnHandle : columnHandles.keySet()) {
代码示例来源: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);
}
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
Map<String, ColumnHandle> columns = metadata.getColumnHandles(session, insert.getTarget());
ImmutableMap.Builder<Symbol, Expression> assignments = ImmutableMap.builder();
for (ColumnMetadata column : tableMetadata.getVisibleColumns()) {
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
内容来源于网络,如有侵权,请联系作者删除!