use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class InformationSchemaMetadata method getColumnMetadata.
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) {
InformationSchemaTableHandle informationSchemaTableHandle = checkTableHandle(tableHandle);
ConnectorTableMetadata tableMetadata = TABLES.get(informationSchemaTableHandle.getSchemaTableName());
String columnName = ((InformationSchemaColumnHandle) columnHandle).getColumnName();
ColumnMetadata columnMetadata = findColumnMetadata(tableMetadata, columnName);
checkArgument(columnMetadata != null, "Column %s on table %s does not exist", columnName, tableMetadata.getTable());
return columnMetadata;
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class LogicalPlanner method createTableCreationPlan.
private RelationPlan createTableCreationPlan(Analysis analysis, Query query) {
QualifiedObjectName destination = analysis.getCreateTableDestination().get();
RelationPlan plan = createRelationPlan(analysis, query);
ConnectorTableMetadata tableMetadata = createTableMetadata(destination, getOutputTableColumns(plan), analysis.getCreateTableProperties(), analysis.getParameters());
Optional<NewTableLayout> newTableLayout = metadata.getNewTableLayout(session, destination.getCatalogName(), tableMetadata);
List<String> columnNames = tableMetadata.getColumns().stream().filter(column -> !column.isHidden()).map(ColumnMetadata::getName).collect(toImmutableList());
return createTableWriterPlan(analysis, plan, new CreateName(destination.getCatalogName(), tableMetadata, newTableLayout), columnNames, newTableLayout);
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestingMetadata method addColumn.
@Override
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) {
ConnectorTableMetadata tableMetadata = getTableMetadata(session, tableHandle);
SchemaTableName tableName = getTableName(tableHandle);
ImmutableList.Builder<ColumnMetadata> columns = ImmutableList.builder();
columns.addAll(tableMetadata.getColumns());
columns.add(column);
tables.put(tableName, new ConnectorTableMetadata(tableName, columns.build(), tableMetadata.getProperties()));
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestingMetadata method createTable.
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata) {
ConnectorTableMetadata existingTable = tables.putIfAbsent(tableMetadata.getTable(), tableMetadata);
checkArgument(existingTable == null, "Table %s already exists", tableMetadata.getTable());
}
use of com.facebook.presto.spi.ConnectorTableMetadata in project presto by prestodb.
the class TestingMetadata method getTableMetadata.
@Override
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle) {
requireNonNull(tableHandle, "tableHandle is null");
SchemaTableName tableName = getTableName(tableHandle);
ConnectorTableMetadata tableMetadata = tables.get(tableName);
checkArgument(tableMetadata != null, "Table %s does not exist", tableName);
return tableMetadata;
}
Aggregations