use of com.facebook.presto.spi.ColumnMetadata in project presto by prestodb.
the class TableStatsSystemTable method buildPages.
private static List<Page> buildPages(MetadataDao dao, TupleDomain<Integer> tupleDomain) {
Map<Integer, NullableValue> domainValues = extractFixedValues(tupleDomain).orElse(ImmutableMap.of());
String schemaName = getStringValue(domainValues.get(getColumnIndex(METADATA, SCHEMA_NAME)));
String tableName = getStringValue(domainValues.get(getColumnIndex(METADATA, TABLE_NAME)));
PageListBuilder pageBuilder = new PageListBuilder(METADATA.getColumns().stream().map(ColumnMetadata::getType).collect(toList()));
for (TableStatsRow row : dao.getTableStatsRows(schemaName, tableName)) {
pageBuilder.beginRow();
VARCHAR.writeSlice(pageBuilder.nextBlockBuilder(), utf8Slice(row.getSchemaName()));
VARCHAR.writeSlice(pageBuilder.nextBlockBuilder(), utf8Slice(row.getTableName()));
TIMESTAMP.writeLong(pageBuilder.nextBlockBuilder(), row.getCreateTime());
TIMESTAMP.writeLong(pageBuilder.nextBlockBuilder(), row.getUpdateTime());
BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getTableVersion());
BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getShardCount());
BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getRowCount());
BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getCompressedSize());
BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getUncompressedSize());
}
return pageBuilder.build();
}
use of com.facebook.presto.spi.ColumnMetadata in project presto by prestodb.
the class TestRaptorConnector method createTable.
private long createTable(String name) {
ConnectorTransactionHandle transaction = connector.beginTransaction(READ_COMMITTED, false);
connector.getMetadata(transaction).createTable(SESSION, new ConnectorTableMetadata(new SchemaTableName("test", name), ImmutableList.of(new ColumnMetadata("id", BIGINT))));
connector.commit(transaction);
transaction = connector.beginTransaction(READ_COMMITTED, false);
ConnectorTableHandle tableHandle = getTableHandle(connector.getMetadata(transaction), name);
connector.commit(transaction);
return ((RaptorTableHandle) tableHandle).getTableId();
}
use of com.facebook.presto.spi.ColumnMetadata in project presto by prestodb.
the class BlackHoleMetadata method getNewTableLayout.
@Override
public Optional<ConnectorNewTableLayout> getNewTableLayout(ConnectorSession connectorSession, ConnectorTableMetadata tableMetadata) {
List<String> distributeColumns = (List<String>) tableMetadata.getProperties().get(DISTRIBUTED_ON);
if (distributeColumns.isEmpty()) {
return Optional.empty();
}
Set<String> undefinedColumns = Sets.difference(ImmutableSet.copyOf(distributeColumns), tableMetadata.getColumns().stream().map(ColumnMetadata::getName).collect(toSet()));
if (!undefinedColumns.isEmpty()) {
throw new PrestoException(INVALID_TABLE_PROPERTY, "Distribute columns not defined on table: " + undefinedColumns);
}
return Optional.of(new ConnectorNewTableLayout(BlackHolePartitioningHandle.INSTANCE, distributeColumns));
}
use of com.facebook.presto.spi.ColumnMetadata in project presto by prestodb.
the class MemoryColumnHandle method extractColumnHandles.
public static List<MemoryColumnHandle> extractColumnHandles(List<ColumnMetadata> columns) {
ImmutableList.Builder<MemoryColumnHandle> columnHandles = ImmutableList.builder();
int columnIndex = 0;
for (ColumnMetadata column : columns) {
columnHandles.add(new MemoryColumnHandle(column, columnIndex));
columnIndex++;
}
return columnHandles.build();
}
use of com.facebook.presto.spi.ColumnMetadata in project presto by prestodb.
the class TpchMetadata method getTableMetadata.
private static ConnectorTableMetadata getTableMetadata(String schemaName, TpchTable<?> tpchTable) {
ImmutableList.Builder<ColumnMetadata> columns = ImmutableList.builder();
for (TpchColumn<? extends TpchEntity> column : tpchTable.getColumns()) {
columns.add(new ColumnMetadata(column.getColumnName(), getPrestoType(column.getType())));
}
columns.add(new ColumnMetadata(ROW_NUMBER_COLUMN_NAME, BIGINT, null, true));
SchemaTableName tableName = new SchemaTableName(schemaName, tpchTable.getTableName());
return new ConnectorTableMetadata(tableName, columns.build());
}
Aggregations