use of com.netflix.metacat.common.server.connectors.exception.TableNotFoundException in project metacat by Netflix.
the class TagV1Resource method removeTableTags.
/**
* {@inheritDoc}
*/
@Override
public void removeTableTags(final String catalogName, final String databaseName, final String tableName, final Boolean deleteAll, final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
requestWrapper.processRequest(name, "TagV1Resource.removeTableTags", () -> {
if (!tableService.exists(name)) {
// Delete tags if exists
tagService.delete(name, false);
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
tagService.removeTableTags(name, deleteAll, tags, true);
final TableDto currentTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return null;
});
}
use of com.netflix.metacat.common.server.connectors.exception.TableNotFoundException in project metacat by Netflix.
the class TagV1Resource method setTableTags.
/**
* {@inheritDoc}
*/
@Override
public Set<String> setTableTags(final String catalogName, final String databaseName, final String tableName, final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
return requestWrapper.processRequest(name, "TagV1Resource.setTableTags", () -> {
if (!tableService.exists(name)) {
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
final Set<String> result = tagService.setTableTags(name, tags, true);
final TableDto currentTable = this.tableService.get(name, true).orElseThrow(IllegalStateException::new);
eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return result;
});
}
use of com.netflix.metacat.common.server.connectors.exception.TableNotFoundException in project metacat by Netflix.
the class S3ConnectorTableService method rename.
@Override
public void rename(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName oldName, @Nonnull final QualifiedName newName) {
log.debug("Start: Rename table {} with {}", oldName, newName);
final Table oldTable = tableDao.getBySourceDatabaseTableName(catalogName, oldName.getDatabaseName(), oldName.getTableName());
if (oldTable == null) {
throw new TableNotFoundException(oldName);
}
final Table newTable = tableDao.getBySourceDatabaseTableName(catalogName, newName.getDatabaseName(), newName.getTableName());
if (newTable == null) {
oldTable.setName(newName.getTableName());
tableDao.save(oldTable);
} else {
throw new TableAlreadyExistsException(newName);
}
log.debug("End: Rename table {} with {}", oldName, newName);
}
use of com.netflix.metacat.common.server.connectors.exception.TableNotFoundException in project metacat by Netflix.
the class S3ConnectorTableService method get.
@Override
public TableInfo get(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
final Table table = tableDao.getBySourceDatabaseTableName(catalogName, name.getDatabaseName(), name.getTableName());
if (table == null) {
throw new TableNotFoundException(name);
}
log.debug("Get table {}", name);
return infoConverter.toTableInfo(name, table);
}
use of com.netflix.metacat.common.server.connectors.exception.TableNotFoundException in project metacat by Netflix.
the class HiveConnectorPartitionService method getPartitionKeys.
/**
* {@inheritDoc}.
*/
@Override
public List<String> getPartitionKeys(final ConnectorRequestContext requestContext, final QualifiedName tableName, final PartitionListRequest partitionsRequest) {
final String filterExpression = partitionsRequest.getFilter();
final List<String> partitionIds = partitionsRequest.getPartitionNames();
List<String> names = Lists.newArrayList();
final Pageable pageable = partitionsRequest.getPageable();
try {
if (filterExpression != null || (partitionIds != null && !partitionIds.isEmpty())) {
final Table table = metacatHiveClient.getTableByName(tableName.getDatabaseName(), tableName.getTableName());
for (Partition partition : getPartitions(tableName, filterExpression, partitionIds, partitionsRequest.getSort(), pageable)) {
names.add(getNameOfPartition(table, partition));
}
} else {
names = metacatHiveClient.getPartitionNames(tableName.getDatabaseName(), tableName.getTableName());
return ConnectorUtils.paginate(names, pageable);
}
} catch (NoSuchObjectException exception) {
throw new TableNotFoundException(tableName, exception);
} catch (MetaException | InvalidObjectException e) {
throw new InvalidMetaException("Invalid metadata for " + tableName, e);
} catch (TException e) {
throw new ConnectorException(String.format("Failed get partitions keys for hive table %s", tableName), e);
}
return names;
}
Aggregations