use of com.facebook.presto.raptor.storage.StorageTypeConverter in project presto by prestodb.
the class RaptorMetadata method addColumn.
@Override
public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) {
RaptorTableHandle table = (RaptorTableHandle) tableHandle;
// Always add new columns to the end.
List<TableColumn> existingColumns = dao.listTableColumns(table.getSchemaName(), table.getTableName());
TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1);
long columnId = lastColumn.getColumnId() + 1;
int ordinalPosition = lastColumn.getOrdinalPosition() + 1;
StorageTypeConverter storageTypeConverter = new StorageTypeConverter(typeManager);
checkState(storageTypeConverter.toStorageType(column.getType()) != null, "storage type cannot be null");
String type = column.getType().getTypeSignature().toString();
daoTransaction(dbi, MetadataDao.class, dao -> {
dao.insertColumn(table.getTableId(), columnId, column.getName(), ordinalPosition, type, null, null);
dao.updateTableVersion(table.getTableId(), session.getStartTime());
});
shardManager.addColumn(table.getTableId(), new ColumnInfo(columnId, column.getType()));
}
use of com.facebook.presto.raptor.storage.StorageTypeConverter in project presto by prestodb.
the class RaptorMetadata method getNewTableLayout.
@Override
public Optional<ConnectorNewTableLayout> getNewTableLayout(ConnectorSession session, ConnectorTableMetadata metadata) {
ImmutableMap.Builder<String, RaptorColumnHandle> map = ImmutableMap.builder();
long columnId = 1;
StorageTypeConverter storageTypeConverter = new StorageTypeConverter(typeManager);
for (ColumnMetadata column : metadata.getColumns()) {
checkState(storageTypeConverter.toStorageType(column.getType()) != null, "storage type cannot be null");
map.put(column.getName(), new RaptorColumnHandle(connectorId, column.getName(), columnId, column.getType()));
columnId++;
}
Optional<DistributionInfo> distribution = getOrCreateDistribution(map.build(), metadata.getProperties());
if (!distribution.isPresent()) {
return Optional.empty();
}
List<String> partitionColumns = distribution.get().getBucketColumns().stream().map(RaptorColumnHandle::getColumnName).collect(toList());
ConnectorPartitioningHandle partitioning = getPartitioningHandle(distribution.get().getDistributionId());
return Optional.of(new ConnectorNewTableLayout(partitioning, partitionColumns));
}
Aggregations