use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method get_table.
/**
* {@inheritDoc}
*/
@Override
public Table get_table(final String dbname, final String tblName) throws TException {
return requestWrapper("get_table", new Object[] { dbname, tblName }, () -> {
final String databaseName = normalizeIdentifier(dbname);
final String tableName = normalizeIdentifier(tblName);
final TableDto dto = v1.getTable(catalogName, databaseName, tableName, true, true, true);
return hiveConverters.metacatToHiveTable(dto);
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method create_table_with_environment_context.
/**
* {@inheritDoc}
*/
@Override
public void create_table_with_environment_context(final Table tbl, @Nullable final EnvironmentContext environmentContext) throws TException {
requestWrapper("create_table_with_environment_context", new Object[] { tbl, environmentContext }, () -> {
final String dbname = normalizeIdentifier(tbl.getDbName());
final String tblName = normalizeIdentifier(tbl.getTableName());
final QualifiedName name = QualifiedName.ofTable(catalogName, dbname, tblName);
final TableDto dto = hiveConverters.hiveToMetacatTable(name, tbl);
v1.createTable(catalogName, dbname, tblName, dto);
return null;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class TagController method setTableTags.
/**
* Sets the tags on the given table.
*
* @param catalogName catalog name
* @param databaseName database name
* @param tableName table name
* @param tags set of tags
* @return set of tags
*/
@RequestMapping(method = RequestMethod.POST, path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(position = 2, value = "Sets the tags on the given table", notes = "Sets the tags on the given table")
@ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "The tags were successfully created on the table"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested catalog or database or table cannot be located") })
public Set<String> setTableTags(@ApiParam(value = "The name of the catalog", required = true) @PathVariable("catalog-name") final String catalogName, @ApiParam(value = "The name of the database", required = true) @PathVariable("database-name") final String databaseName, @ApiParam(value = "The name of the table", required = true) @PathVariable("table-name") final String tableName, @ApiParam(value = "Set of tags", required = true) @RequestBody final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = this.requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
return this.requestWrapper.processRequest(name, "TagV1Resource.setTableTags", () -> {
// TODO: shouldn't this be in the tag service?
if (!this.tableService.exists(name)) {
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, GetTableServiceParameters.builder().includeInfo(true).includeDataMetadata(true).includeDefinitionMetadata(true).disableOnReadMetadataIntercetor(false).build()).orElseThrow(IllegalStateException::new);
final Set<String> result = this.tagService.setTableTags(name, tags, true);
final TableDto currentTable = this.tableService.get(name, GetTableServiceParameters.builder().includeInfo(true).includeDataMetadata(true).includeDefinitionMetadata(true).disableOnReadMetadataIntercetor(false).build()).orElseThrow(IllegalStateException::new);
this.eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return result;
});
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class MetacatServiceHelper method postPreUpdateEvent.
/**
* Calls the right method of the event bus for the given qualified name.
*
* @param name name
* @param metacatRequestContext context
* @param dto dto
*/
public void postPreUpdateEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext, final BaseDto dto) {
if (name.isPartitionDefinition()) {
final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
if (dto != null) {
partitionsSaveRequestDto.setPartitions(ImmutableList.of((PartitionDto) dto));
}
this.eventBus.postSync(new MetacatSaveTablePartitionPreEvent(name, metacatRequestContext, this, partitionsSaveRequestDto));
} else if (name.isViewDefinition()) {
this.eventBus.postSync(new MetacatUpdateMViewPreEvent(name, metacatRequestContext, this, (TableDto) dto));
} else if (name.isTableDefinition()) {
this.eventBus.postSync(new MetacatUpdateTablePreEvent(name, metacatRequestContext, this, (TableDto) dto, (TableDto) dto));
} else if (name.isDatabaseDefinition()) {
eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
} else {
throw new IllegalArgumentException(String.format("Invalid name %s", name));
}
}
use of com.netflix.metacat.common.dto.TableDto in project metacat by Netflix.
the class MViewServiceImpl method updateAndReturn.
/**
* {@inheritDoc}
*/
@Override
public TableDto updateAndReturn(final QualifiedName name, final TableDto tableDto) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
eventBus.postSync(new MetacatUpdateMViewPreEvent(name, metacatRequestContext, this, tableDto));
final QualifiedName viewQName = QualifiedName.ofTable(name.getCatalogName(), VIEW_DB_NAME, createViewName(name));
log.info("Updating view {}.", viewQName);
tableService.update(viewQName, tableDto);
final TableDto updatedDto = getOpt(name, GetTableServiceParameters.builder().includeInfo(true).includeDefinitionMetadata(false).includeDataMetadata(false).disableOnReadMetadataIntercetor(false).build()).orElseThrow(() -> new IllegalStateException("should exist"));
eventBus.postAsync(new MetacatUpdateMViewPostEvent(name, metacatRequestContext, this, updatedDto));
return updatedDto;
}
Aggregations