use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class S3ConnectorTableService method create.
@Override
public void create(@Nonnull final ConnectorContext context, @Nonnull final TableInfo tableInfo) {
log.debug("Start: Create table {}", tableInfo.getName());
Preconditions.checkArgument(tableInfo.getSerde() == null || !Strings.isNullOrEmpty(tableInfo.getSerde().getOwner()), "Table owner is null or empty");
final QualifiedName tableName = tableInfo.getName();
if (tableDao.getBySourceDatabaseTableName(catalogName, tableName.getDatabaseName(), tableName.getTableName()) != null) {
throw new TableAlreadyExistsException(tableName);
}
final Database database = databaseDao.getBySourceDatabaseName(catalogName, tableName.getDatabaseName());
if (database == null) {
throw new DatabaseNotFoundException(QualifiedName.ofDatabase(catalogName, tableName.getDatabaseName()));
}
tableDao.save(infoConverter.fromTableInfo(database, tableInfo));
log.debug("End: Create table {}", tableInfo.getName());
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class MetacatV1Resource method createTable.
@Override
public TableDto createTable(final String catalogName, final String databaseName, final String tableName, final TableDto table) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
return requestWrapper.processRequest(name, "createTable", () -> {
Preconditions.checkArgument(table != null, "Table cannot be null");
Preconditions.checkArgument(tableName != null && !tableName.isEmpty(), "table name is required");
Preconditions.checkArgument(table.getName() != null && tableName.equalsIgnoreCase(table.getName().getTableName()), "Table name does not match the name in the table");
return tableService.create(name, table);
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class MetacatV1Resource method updateDatabase.
@Override
public void updateDatabase(final String catalogName, final String databaseName, final DatabaseCreateRequestDto databaseUpdateRequestDto) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
requestWrapper.processRequest(name, "updateDatabase", () -> {
final DatabaseDto newDto = new DatabaseDto();
newDto.setName(name);
newDto.setDefinitionMetadata(databaseUpdateRequestDto.getDefinitionMetadata());
databaseService.update(name, newDto);
return null;
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class MetacatV1Resource method updateCatalog.
@Override
public void updateCatalog(final String catalogName, final CreateCatalogDto createCatalogDto) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofCatalog(catalogName));
requestWrapper.processRequest(name, "updateDatabase", () -> {
createCatalogDto.setName(name);
catalogService.update(name, createCatalogDto);
return null;
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class MetacatV1Resource method deleteDatabase.
@Override
public void deleteDatabase(final String catalogName, final String databaseName) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
requestWrapper.processRequest(name, "deleteDatabase", () -> {
databaseService.delete(name);
return null;
});
}
Aggregations