use of com.netflix.metacat.common.dto.ViewDto in project metacat by Netflix.
the class HiveConvertersImpl method hiveToMetacatTable.
/**
* {@inheritDoc}
*/
@Override
public TableDto hiveToMetacatTable(final QualifiedName name, final Table table) {
final TableDto dto = new TableDto();
dto.setSerde(toStorageDto(table.getSd(), table.getOwner()));
dto.setAudit(new AuditDto());
dto.setName(name);
if (table.isSetCreateTime()) {
dto.getAudit().setCreatedDate(epochSecondsToDate(table.getCreateTime()));
}
dto.setMetadata(table.getParameters());
final List<FieldSchema> nonPartitionColumns = table.getSd().getCols();
final List<FieldSchema> partitionColumns = table.getPartitionKeys();
final List<FieldDto> allFields = Lists.newArrayListWithCapacity(nonPartitionColumns.size() + partitionColumns.size());
nonPartitionColumns.stream().map(field -> this.hiveToMetacatField(field, false)).forEachOrdered(allFields::add);
partitionColumns.stream().map(field -> this.hiveToMetacatField(field, true)).forEachOrdered(allFields::add);
dto.setFields(allFields);
dto.setView(new ViewDto(table.getViewOriginalText(), table.getViewExpandedText()));
return dto;
}
use of com.netflix.metacat.common.dto.ViewDto in project metacat by Netflix.
the class HiveConvertersImpl method updateTableTypeAndViewInfo.
private void updateTableTypeAndViewInfo(final TableDto dto, final Table table) {
final ViewDto viewDto = dto.getView();
if (null == dto.getView() || Strings.isNullOrEmpty(viewDto.getViewOriginalText())) {
table.setTableType(TableType.EXTERNAL_TABLE.name());
return;
}
table.setTableType(TableType.VIRTUAL_VIEW.name());
table.setViewOriginalText(viewDto.getViewOriginalText());
table.setViewExpandedText(viewDto.getViewExpandedText());
}
Aggregations