use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.
the class S3ConnectorPartitionService method create.
@Override
public void create(@Nonnull final ConnectorContext context, @Nonnull final PartitionInfo partitionInfo) {
final QualifiedName name = partitionInfo.getName();
log.debug("Start: Create partition {}", name);
final QualifiedName tableName = QualifiedName.ofTable(catalogName, name.getDatabaseName(), name.getTableName());
// Table
final Table table = getTable(tableName);
final List<Partition> partitions = partitionDao.getPartitions(table.getId(), Lists.newArrayList(name.getPartitionName()), null, null, null, null);
if (!partitions.isEmpty()) {
throw new PartitionAlreadyExistsException(tableName, name.getPartitionName());
}
partitionDao.save(infoConverter.toPartition(table, partitionInfo));
log.debug("End: Create partition {}", name);
}
use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.
the class S3ConnectorTableService method delete.
@Override
public void delete(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
log.debug("Start: Delete table {}", name);
final Table table = tableDao.getBySourceDatabaseTableName(catalogName, name.getDatabaseName(), name.getTableName());
if (table == null) {
throw new TableNotFoundException(name);
}
tableDao.delete(table);
log.debug("End: Delete table {}", name);
}
use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.
the class S3ConnectorInfoConverter method fromTableInfo.
@Override
public Table fromTableInfo(final TableInfo tableInfo) {
final Table result = new Table();
result.setName(tableInfo.getName().getTableName());
final Location location = toLocation(tableInfo);
if (location != null) {
result.setLocation(location);
location.setTable(result);
}
return result;
}
use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.
the class S3ConnectorInfoConverter method getOwner.
/**
* Gets the owner for the given table.
* @param table table info
* @return owner name
*/
public String getOwner(final Table table) {
String result = null;
final Location location = table.getLocation();
if (location != null) {
final Info info = location.getInfo();
if (info != null) {
result = info.getOwner();
}
}
return result;
}
use of com.netflix.metacat.connector.s3.model.Table in project metacat by Netflix.
the class S3ConnectorInfoConverter method toStorageInfo.
/**
* Converts from s3 table info to storage info.
* @param table table info
* @return table info
*/
StorageInfo toStorageInfo(final Table table) {
StorageInfo result = null;
final Location location = table.getLocation();
if (location != null) {
final Map<String, String> infoParameters = Maps.newHashMap();
result = new StorageInfo();
result.setUri(location.getUri());
final Info info = location.getInfo();
if (info != null) {
result.setOwner(info.getOwner());
result.setInputFormat(info.getInputFormat());
result.setOutputFormat(info.getOutputFormat());
result.setSerializationLib(info.getSerializationLib());
if (info.getParameters() != null) {
infoParameters.putAll(info.getParameters());
}
}
result.setSerdeInfoParameters(infoParameters);
result.setParameters(Maps.newHashMap());
}
return result;
}
Aggregations