本文整理了Java中com.facebook.presto.metadata.Metadata.getTableMetadata()
方法的一些代码示例,展示了Metadata.getTableMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getTableMetadata()
方法的具体详情如下:
包路径:com.facebook.presto.metadata.Metadata
类名称:Metadata
方法名:getTableMetadata
[英]Return the metadata for the specified table handle.
[中]返回指定表句柄的元数据。
代码示例来源:origin: prestodb/presto
@Override
public Void visitIndexSource(IndexSourceNode node, Void context)
{
TableHandle tableHandle = node.getTableHandle();
Set<Column> columns = new HashSet<>();
for (ColumnHandle columnHandle : node.getAssignments().values()) {
columns.add(createColumn(metadata.getColumnMetadata(session, tableHandle, columnHandle)));
}
inputs.add(createInput(metadata.getTableMetadata(session, tableHandle), node.getLayout(), columns));
return null;
}
代码示例来源:origin: prestodb/presto
@Override
public Void visitTableScan(TableScanNode node, Void context)
{
TableHandle tableHandle = node.getTable();
Set<Column> columns = new HashSet<>();
for (ColumnHandle columnHandle : node.getAssignments().values()) {
columns.add(createColumn(metadata.getColumnMetadata(session, tableHandle, columnHandle)));
}
inputs.add(createInput(metadata.getTableMetadata(session, tableHandle), node.getLayout(), columns));
return null;
}
代码示例来源:origin: prestodb/presto
TableMetadata tableMetadata = metadata.getTableMetadata(session, targetTableHandle.get());
List<String> tableColumns = tableMetadata.getColumns().stream()
.filter(column -> !column.isHidden())
代码示例来源:origin: prestodb/presto
if (metadata.getTableMetadata(session, tableHandle).getColumns().stream()
.filter(info -> !info.isHidden()).count() <= 1) {
throw new SemanticException(NOT_SUPPORTED, statement, "Cannot drop the only column in a table");
代码示例来源:origin: prestodb/presto
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
TableScanNode tableScanNode = (TableScanNode) node;
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableScanNode.getTable());
String actualTableName = tableMetadata.getTable().getTableName();
return new MatchResult(
expectedTableName.equalsIgnoreCase(actualTableName) &&
((!expectedConstraint.isPresent()) ||
domainsMatch(expectedConstraint, tableScanNode.getCurrentConstraint(), tableScanNode.getTable(), session, metadata)) &&
hasTableLayout(tableScanNode));
}
代码示例来源:origin: prestodb/presto
ConnectorTableMetadata connectorTableMetadata = metadata.getTableMetadata(session, tableHandle.get()).getMetadata();
代码示例来源:origin: prestodb/presto
symbolAllocator.newSymbol("fragment", VARBINARY));
return new DeleteNode(idAllocator.getNextId(), builder.getRoot(), new DeleteHandle(handle, metadata.getTableMetadata(session, handle).getTable()), rowId, outputs);
代码示例来源:origin: prestodb/presto
@Override
public Optional<Symbol> getAssignedSymbol(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
TableHandle tableHandle;
Map<Symbol, ColumnHandle> assignments;
if (node instanceof TableScanNode) {
TableScanNode tableScanNode = (TableScanNode) node;
tableHandle = tableScanNode.getTable();
assignments = tableScanNode.getAssignments();
}
else if (node instanceof IndexSourceNode) {
IndexSourceNode indexSourceNode = (IndexSourceNode) node;
tableHandle = indexSourceNode.getTableHandle();
assignments = indexSourceNode.getAssignments();
}
else {
return Optional.empty();
}
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableHandle);
String actualTableName = tableMetadata.getTable().getTableName();
// Wrong table -> doesn't match.
if (!tableName.equalsIgnoreCase(actualTableName)) {
return Optional.empty();
}
Optional<ColumnHandle> columnHandle = getColumnHandle(tableHandle, session, metadata);
checkState(columnHandle.isPresent(), format("Table %s doesn't have column %s. Typo in test?", tableName, columnName));
return getAssignedSymbol(assignments, columnHandle.get());
}
代码示例来源:origin: prestodb/presto
private TableWriterNode.WriterTarget createWriterTarget(TableWriterNode.WriterTarget target)
{
// TODO: begin these operations in pre-execution step, not here
// TODO: we shouldn't need to store the schemaTableName in the handles, but there isn't a good way to pass this around with the current architecture
if (target instanceof TableWriterNode.CreateName) {
TableWriterNode.CreateName create = (TableWriterNode.CreateName) target;
return new TableWriterNode.CreateHandle(metadata.beginCreateTable(session, create.getCatalog(), create.getTableMetadata(), create.getLayout()), create.getTableMetadata().getTable());
}
if (target instanceof TableWriterNode.InsertReference) {
TableWriterNode.InsertReference insert = (TableWriterNode.InsertReference) target;
return new TableWriterNode.InsertHandle(metadata.beginInsert(session, insert.getHandle()), metadata.getTableMetadata(session, insert.getHandle()).getTable());
}
if (target instanceof TableWriterNode.DeleteHandle) {
TableWriterNode.DeleteHandle delete = (TableWriterNode.DeleteHandle) target;
return new TableWriterNode.DeleteHandle(metadata.beginDelete(session, delete.getHandle()), delete.getSchemaTableName());
}
throw new IllegalArgumentException("Unhandled target type: " + target.getClass().getSimpleName());
}
代码示例来源:origin: prestodb/presto
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases)
{
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
IndexSourceNode indexSourceNode = (IndexSourceNode) node;
TableMetadata tableMetadata = metadata.getTableMetadata(session, indexSourceNode.getTableHandle());
String actualTableName = tableMetadata.getTable().getTableName();
if (!expectedTableName.equalsIgnoreCase(actualTableName)) {
return NO_MATCH;
}
if (expectedConstraint.isPresent() &&
!domainsMatch(
expectedConstraint,
indexSourceNode.getCurrentConstraint(),
indexSourceNode.getTableHandle(),
session,
metadata)) {
return NO_MATCH;
}
return match();
}
代码示例来源:origin: prestodb/presto
.orElseThrow(() -> new SemanticException(MISSING_TABLE, statement, "LIKE table '%s' does not exist", likeTableName));
TableMetadata likeTableMetadata = metadata.getTableMetadata(session, likeTable);
代码示例来源:origin: prestodb/presto
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableHandle.get());
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
代码示例来源:origin: prestodb/presto
@Override
public Void visitTableScan(TableScanNode node, IOPlanBuilder context)
{
TableMetadata tableMetadata = metadata.getTableMetadata(session, node.getTable());
context.addInputTableColumnInfo(new IOPlan.TableColumnInfo(
new CatalogSchemaTableName(
tableMetadata.getConnectorId().getCatalogName(),
tableMetadata.getTable().getSchemaName(),
tableMetadata.getTable().getTableName()),
parseConstraints(node.getTable(), node.getCurrentConstraint())));
return null;
}
代码示例来源: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
private TableMetadata getTableMetadata(String catalog, String schema, String tableName)
{
Session session = getSession();
Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata();
return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl())
.readOnly()
.execute(session, transactionSession -> {
Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, schema, tableName));
assertTrue(tableHandle.isPresent());
return metadata.getTableMetadata(transactionSession, tableHandle.get());
});
}
代码示例来源:origin: prestodb/presto
TableMetadata tableMetadata = metadata.getTableMetadata(session, insert.getTarget());
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Override
public Void visitTableScan(TableScanNode node, Void context)
{
TableHandle tableHandle = node.getTable();
Optional<ColumnHandle> sampleWeightColumn = metadata.getSampleWeightColumnHandle(session, tableHandle);
Set<Column> columns = new HashSet<>();
for (ColumnHandle columnHandle : node.getAssignments().values()) {
if (!columnHandle.equals(sampleWeightColumn.orElse(null))) {
columns.add(createColumnEntry(metadata.getColumnMetadata(session, tableHandle, columnHandle)));
}
}
inputs.put(createTableEntry(metadata.getTableMetadata(session, tableHandle)), columns);
return null;
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Override
public Void visitIndexSource(IndexSourceNode node, Void context)
{
TableHandle tableHandle = node.getTableHandle();
Optional<ColumnHandle> sampleWeightColumn = metadata.getSampleWeightColumnHandle(session, tableHandle);
Set<Column> columns = new HashSet<>();
for (ColumnHandle columnHandle : node.getAssignments().values()) {
if (!columnHandle.equals(sampleWeightColumn.orElse(null))) {
columns.add(createColumnEntry(metadata.getColumnMetadata(session, tableHandle, columnHandle)));
}
}
inputs.put(createTableEntry(metadata.getTableMetadata(session, tableHandle)), columns);
return null;
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-hive
private TableMetadata getTableMetadata(String tableName)
{
Session session = getSession();
Metadata metadata = ((DistributedQueryRunner) queryRunner).getCoordinator().getMetadata();
return transaction(queryRunner.getTransactionManager())
.readOnly()
.execute(session, transactionSession -> {
Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(HIVE_CATALOG, TPCH_SCHEMA, tableName));
assertTrue(tableHandle.isPresent());
return metadata.getTableMetadata(transactionSession, tableHandle.get());
});
}
代码示例来源:origin: com.facebook.presto/presto-hive
private TableMetadata getTableMetadata(String catalog, String schema, String tableName)
{
Session session = getSession();
Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata();
return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl())
.readOnly()
.execute(session, transactionSession -> {
Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, schema, tableName));
assertTrue(tableHandle.isPresent());
return metadata.getTableMetadata(transactionSession, tableHandle.get());
});
}
内容来源于网络,如有侵权,请联系作者删除!